Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenPop.Pop3.Exceptions.InvalidLoginException: 'Server did not accept user credentials'

Tags:

c#

gmail

I am using the following code to read from Gmail:

using (Pop3Client client = new Pop3Client())
        {
            // Connect to the server
            client.Connect("pop.gmail.com", 995, true);       

            client.Authenticate("recent:[email protected]", "password1", OpenPop.Pop3.AuthenticationMethod.UsernameAndPassword);

Note that I can login with the credentials (note I have tweaked the username, password for security).

I keep in getting:

I keep on getting a message:

OpenPop.Pop3.Exceptions.InvalidLoginException: 'Server did not accept user credentials'

Note that I have enable POP in Gmail Setting. Gmail shows: Status: POP is enabled for all mail

like image 478
Nate Pet Avatar asked May 02 '18 13:05

Nate Pet


2 Answers

Google accounts will only allow POP3 access if you have enabled the "less secure apps" feature. This can be done from this link: https://www.google.com/settings/security/lesssecureapps

However, if you have two-factor authentication enabled you won't be able to turn this setting on. Instead you can create a specific set of credentials that will also give you access. That can be done via this link: https://security.google.com/settings/security/apppasswords

The latter method is probably a better option anyway as it means you can delete that password without having to change your main account details.

like image 149
DavidG Avatar answered Sep 18 '22 20:09

DavidG



I am suffering same Issue and I found the solution this way, and i will describe here.
1-enable the pop at Configurations / Forwarding and POP/IMAP
2- follow this link: https://www.google.com/settings/security/lesssecureapps and activate for less secure apps.

like image 32
Ravi Shah Avatar answered Sep 17 '22 20:09

Ravi Shah