0 votes

We are using mail client successfully in our production environment, but when trying to test in dev we get authentication errors. I have confirmed the user and password are valid (connecting directly to gmail). Could this be a license issue? I'm trying to add another email listener and unable to test it properly.

imap.SSLConfiguration.EnabledSslProtocols = 
    System.Security.Authentication.SslProtocols.Tls12;

imap.ConnectSSL(Gmail);
imap.Login(User, Password);

imap.SelectInbox();

var uids = imap.Search(Flag.Unseen);

Limilabs.Client.IMAP.ImapResponseException: '[AUTHENTICATIONFAILED] Invalid credentials (Failure)'

by
edited

What is the exact error message?

Can you turn on logging:
https://www.limilabs.com/blog/logging-in-mail-dll

1 Answer

0 votes

This is not a licensing issue.

First, it is generally advised to use Imap.UseBestLogin method instead of Login.

Second, to connect to Gmail you need to use Application specific passwords or OAuth 2.0.

Regular passwords require 'Less secure apps' setting which is available for corporate accounts only.

Application passwords are the easiest way to log-in to your Gmail account using POP3 or IMAP.

You can find all required information here:
https://www.limilabs.com/blog/enable-imap-in-gmail

by (297k points)
edited by

I'm still not understanding though why it's working correctly in our production environment and not our local environment. Nothing is different as far as the credentials are concerned.

This doesn't seem Mail.dll related - error is clear and coming from the server. Maybe you are logging in from a different geographical location and you are being blocked by Gmail.

Consider logging in interactively (using a web browser) from the same location.

...