0 votes

Hello,

I am working on Mail Client application. Everything was working fine and I suddenly get error in yahoo. I have done few research and got that user must set setting of "Turn On less secure app" settings in Yahoo and Gmail account.

I have following code for IMAP Log in for Port 993 which is SSL port.
I want to differentiate error on base of error. Use must come to know whether credential is wrong or user need to set settings of "Turn on less secure app".

For Gmail, on the base of error, I can identify above requirement. But for Yahoo, it throw same error in both the cases. It is really difficult to identify whether credential is wrong or user need to set setting of "Turn on less secure app".

try
{
    using (Imap client = new Imap())
    {
        string authTypes = String.Empty;
        client.ServerCertificateValidate += 
            new ServerCertificateValidateEventHandler(Validate);
        client.ConnectSSL("imap.mail.yahoo.com", 993);
        client.UseBestLogin(emailId, password);

        var authMethods = client.SupportedAuthenticationMethods();
        foreach (var method in authMethods)
            authTypes += method.Name.ToString() + ", ";
    }
}
catch (Exception ex)
{
   //gmail
   //Error for wrong credential: 
   //[AUTHENTICATIONFAILED] Invalid credentials (Failure)
   //
   //For Less Secure app setting: 
   //[ALERT] Please log in via your web browser: 
   //https://support.google.com/mail/accounts/answer/78754 (Failure)

   //yahoo:
   //Error for Less Secure apps: 
   //[AUTHENTICATIONFAILED] (#MBR1212) Incorrect username or password.
   //Error for wrong credential: 
   //[AUTHENTICATIONFAILED] (#MBR1212) Incorrect username or password.
}

Please review above code and suggest me how to identify both error. Otherwise end user will consider wrong credential and they will try again and again even credential will be correct

by (3.0k points)
edited by

1 Answer

0 votes

If the Yahoo error messages are the same there is no way to guess the error type.

Please consider asking Yahoo support for details.

by (301k points)
I never contacted to yahoo support for development. Can you please suggest me link for email development issues for Yahoo?
I don't know that - sorry.
...