Jump to content
Ian Branch

Problem logging into gmail..

Recommended Posts

Hi Team,

Win 11, D11.2, Indy as it came with D11.2.

I am trying to receive emails from GMail so I can process them.

I have the following code..

.....
with POP3 do
    begin
      Host := 'pop.gmail.com';
      Username := 'MyUserName@gmail.com';
      Password := 'MyPassword';
      Port := 995;
      IOHandler := IdSSLIOHandlerSocketOpenSSL;
      UseTLS := utUseImplicitTLS;
    end;
    with IdSSLIOHandlerSocketOpenSSL do
    begin
      Destination := 'pop.gmail.com:995';
      SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
      Host := 'pop.gmail.com';
      Port := 995;
      DefaultPort := 0;
    end;
    POP3.Connect;
....

When run and it attempts to connect I get an error. "Username and password not accepted."

I have verified and even reset my gmail password to no avail.

I am clearly missing something, or is it a GMail thing....

Thoughts, suggestions, education appreciated.

Regards & TIA,

Ian

Edited by Ian Branch

Share this post


Link to post
1 hour ago, Ian Branch said:

I have verified and even reset my gmail password to no avail.

Are you using your gmail password there? That hasn't worked in months.

See https://support.google.com/accounts/answer/6010255

 

You can't use your username and gmail password anymore.

You need to enable 2FA and create and use an App password.

See https://support.google.com/accounts/answer/185833

 

Share this post


Link to post

Yes. That includes IMAP access.

 

The complete "Less secure app access" option isn't available anymore.

See https://myaccount.google.com/lesssecureapps

 

And I thought App passwords were only available when you switch on 2FA.

Other option is OAuth2 (which is even more a pain).

 

Edited by rvk

Share this post


Link to post
6 hours ago, rvk said:

Other option is OAuth2 (which is even more a pain).

FYI, there is a sasl-oauth branch in Indy's GitHub repo to add OAuth2 SASL components for TIdSMTP/TIdPOP3/TIdIMAP4 (and TIdDICT).  You would still have to obtain/refresh the OAuth2 token yourself from Google (or other OAuth2 provider), such as via HTTP, but Indy can then submit the token via SASL when accessing email.

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×