Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Email and FTP no longer working
#4
(06-19-2023, 09:13 PM)OldBob1938 Wrote: Thanks for the code to capture the error.  The error is "support.google.com BadCredentials" + plus a long string of characters.  I do not understand this at all. 

See bad credentials using gmail smtp.

(06-19-2023, 09:13 PM)OldBob1938 Wrote: I can send email via ordinary gmail using these same credentails.   If there were some issue with Indy I would expect that I wouldn't be alone with this problem.

Using your real Gmail credentials with TIdSMTP::AuthType = satDefault only works if you have Access for less secure apps enabled in your Gmail account.

Otherwise, if you have Multi-Factor Authentication enabled in your Gmail account, you can use satDefault with Gmail only if you use an App-Specific password instead of your real password.

Otherwise, you must use OAuth2 authentication to use your real Gmail credentials.

To use OAuth2 with TIdSMTP (amongst other components), you must do the following:
  • set TIdSMTP::AuthType = satSASL
  • add a TIdSASLXOAuth2 object to the TIdSMTP::SASLMechanisms property
  • assign a TIdUserPassProvider object to the TIdSASLXOAuth2::UserPassProvider property
  • follow Google's documentation to obtain an access token at runtime
  • set the access token to the TIdUserPassProvider:: Password property
  • connect TIdSMTP to Gmail. The token will be used for authentication, no credentials will be used.

TIdSASLXOAuth2 can be gotten from the sasl-oauth branch of Indy's GitHub repo (as it has not been merged into Indy's master code yet).

(06-19-2023, 09:13 PM)OldBob1938 Wrote: My code has not changed for over a year and has been working fine until early June.  

I seriously doubt that, because this is not a new requirement of Gmail, it has been in place for a long time now.

(06-19-2023, 09:13 PM)OldBob1938 Wrote: I'm using libeay32.dll and ssleay32.dll

Which version of them are you using, exactly?  TIdSSLIOHandlerSocketOpenSSL only supports up to OpenSSL 1.0.2u.  For newer OpenSSL versions, you need to use a WIP SSLIOHandler from PR #299 in Indy's GitHub repo (as it hasn't been merged into the master code yet, either).

(06-19-2023, 09:13 PM)OldBob1938 Wrote:
Code:
gSMTP->Host      = "smtp-relay.gmail.com";

Why are you sending emails through "smtp-relay.gmail.com" instead of "smtp.gmail.com"?

(06-19-2023, 09:13 PM)OldBob1938 Wrote:
Code:
IdSSLIOHandlerSocketOpenSSL1->Destination   = "smtp.gmail.com";
IdSSLIOHandlerSocketOpenSSL1->Host          = "smtp.gmail.com";

You don't need to set those properties manually.  Connect() handles that internally.  Also, it doesn't make sense to set them to a different value than what you are setting the TIdSMTP::Host property to.

(06-19-2023, 09:13 PM)OldBob1938 Wrote:
Code:
IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method   = sslvTLSv1;

Although Gmail does currently still support TLS 1.0, most service providers don't anymore, and it is only a matter of time before Gmail drops it, too.  Also, the SSLOptions->Method property has been deprecated for a very long time, so you shouldn't be using it anymore.  Use the SSLOptions->SSLVersions property instead, and then you can enable TLS 1.1 and TLS 1.2 with it, eg:

Code:
IdSSLIOHandlerSocketOpenSSL1->SSLOptions->SSLVersions = TIdSSLVersions() << sslvTLSv1 << sslvTLSv1_1 << sslvTLSv1_2;

(06-19-2023, 09:13 PM)OldBob1938 Wrote: I don't know if this is what you asked for re configuration.

Yes, it is.

Reply


Messages In This Thread
Email and FTP no longer working - by OldBob1938 - 06-13-2023, 06:01 PM
RE: Email and FTP no longer working - by rlebeau - 06-15-2023, 08:02 PM
RE: Email and FTP no longer working - by rlebeau - 06-19-2023, 10:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)