2
votes

I use TIdPOP3 a lot, and it works great, except for GMail accounts.

Somehow it never works. I tried different combinations and ports, with and without SSL, and it always returns different errors.

My most recent try was to create an 'app specific' password on Gmail, and trying to connect using this password, on port 995. This time it returns 'Connection Closed Gracefully'.

Resolving hostname pop.gmail.com.
Connecting to 172.217.192.108.
Connected.
Disconnected.
Connection Closed Gracefully.

I also tried this:

popb.Host := 'pop.gmail.com';
popb.username := '[email protected]';
popb.password := 'mypassword';
popb.Port := 995;
popb.IOHandler := sslpop;
popb.UseTLS := utUseImplicitTLS;
with sslpop do
begin
  Destination := 'pop.gmail.com:995';
  Host := 'pop.gmail.com';
  Port := 995;
  DefaultPort := 0;
end;

In this last example, it returns this error:

Error connecting with SSL. error:00000006:lib(0):func(0):EVP lib

This specific account I'm trying to fetch has 2-step verification; does this make it impossible to use with Indy?

1
I think you need to enable POP/IMAP settings in GMail. Otherwise, you need to use OAuth2 authentication and REST API calls - John Kouraklis
@JohnKouraklis It was already enabled, my issue was other, as my answer shows. Thanks anyway ! - delphirules
I know for a fact that GMail's 'app specific password' feature works with Indy, because I've tested it many times. On a side note, DON'T set the SSLIOHandler properties you are setting, Connect handles them for you. - Remy Lebeau

1 Answers

3
votes

I could fix the issue by setting Ssloptions.Method := sslvSSLv23.

Here is the full working code :

    pop.Host := 'pop.gmail.com';
    pop.username := '[email protected]';
    pop.password := 'mypassword';
    pop.Port := 995;
    pop.IOHandler := sslpop;
    pop.UseTLS := utUseImplicitTLS;
    with sslpop do
    begin
      Destination := 'pop.gmail.com:995';
      Ssloptions.Method := sslvSSLv23;
      Host := 'pop.gmail.com';
      Port := 995;
      DefaultPort := 0;
    end;