0 votes

Hello,

First thing that I don't know whether I can authenticate GoDaddy account with IMAP.

I have windows application. I have following flow.
Step 1- Check ports with domain name

using (Imap client = new Imap())
{
    client.ServerCertificateValidate += new ServerCertificateValidateEventHandler(Validate);
    IAsyncResult result = client.BeginConnectSSL("webmail.myserver.com");
    bool success = result.AsyncWaitHandle.WaitOne(2500, true);
    client.EndConnect(result);
}

Step 2- If port is working fine, use IMAP to login

try
{
  if(993)
  {
    using (Imap client = new Imap())
    {
        client.ServerCertificateValidate += Validate;
        client.ConnectSSL("webmail.myserver.com");  
        client.UseBestLogin(emailId, password);
    }
  }
  else
  {
    using (Imap client = new Imap())
    {
        client.ServerCertificateValidate += Validate;
        client.Connect("webmail.myserver.com");  
        client.Login(emailId, password);   //get error from here
    }
  }
}
catch(Exception ex){}

In Step 1, both port get success. But in step 2, it goes in catch with exception of "AUTHENTICATION fail". There is no further message.

by (3.0k points)
edited by

1 Answer

+1 vote

1.
You should use Imap.Close in both cases.

2.
Imap.ConnectSSL won't work on port 143 as this port is for plain text connections only. You can use StartTLS to upgrade connection to SSL/TLS later on.

3.
Make sure that your account has IMAP access turned on.
"AUTHENTICATION fail" simply means that you provided incorrect credentials.

4.
Are you sure you use correct email server address - Godaddy uses imap.secureserver.net

by (301k points)
2-Can you please suggest me example or link for 143 and 993 which can support for Godaddy account too?
I don't really understand your question. Your code is correct, credentials are not.

Use Imap.Connect for non-SSL, and Imap.ConnectSSL for SSL/TLS connections. Use StartTLS to upgrade non-SSL connection to secured one. You can read more on how to use SSL/TLS and StartTLS here: https://www.limilabs.com/blog/use-ssl-with-imap
The username and password is correct. I can open that Godaddy account from browser. I have edited my code and also added link of Exception that throws while authenticate using port 143. Can you please review it and let me know if anything need to be set.
You should use Imap.UseBestLogin in both cases . Your code is otherwise correct.

The error is returned by your server, not Mail.dll. It claims the credentials are incorrect.

Are you sure you use correct email server address? (AFAIK Godaddy uses imap.secureserver.net)
Thank you.
I have tried by "imap.secureserver.net" and it worked.
1- Can you please let me know about SMTP? Is it "smtp.secureserver.com"?
2- Now I am bit confuse. When I try to use "webmail.myserver.com" as email server address in Step-1 just to check open port(without login), it give me success. But the same address (webmail.myserver.com) doesn't authenticate. Can you suggest me if I need to set or the reason why it doesn't work?
Please consult godadddy support.
Thank you for your efforts.
...