Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Email and FTP no longer working
#1
Hi, my program which uses indy 10.6.2.0 was working fine until the beginning of June.  It will no longer send emails or ftp.  I don't event know where to start.  My sending code is below and errors skip the first to Catch attempts.  So I have no good idea as to what's up.  Any suggestions?  This is important for our little non profit.  

Code:
try
{
gSMTP->Send(idMsg);
MessageSent = true;
// see text with heading A below
}
catch(const std::runtime_error& re)
{
// speciffic handling for runtime_error
//std::cerr << "Runtime error: " << re.what() << std::endl;
BobMessage("Runtime error: "+String(re.what()));
MessageSent = false;
Close();
}
catch(const std::exception& ex)
{
// speciffic handling for all exceptions extending std::exception, except
// std::runtime_error which is handled explicitly
//std::cerr << "Error occurred: " << ex.what() << std::endl;
BobMessage("Error occurred: "+String(ex.what()));
MessageSent = false;
Close();

}
catch(...)
{
MessageSent = false;
BobMessage("Failure on Send to "+ ToEdit->Text+"\nConnect seemed to work");
Close();
// see text with heading B below
}


Any help I can get will be appreciated.  I'm out of my depth.

Bob
Reply
#2
(06-13-2023, 06:01 PM)OldBob1938 Wrote: Hi, my program which uses indy 10.6.2.0 was working fine until the beginning of June.

So, what changed at the beginning of June? Did you change your code? Did your service provider(s) change their system(s)? Things don't just break out of thin air. Something had to have changed to make your project stop working.

(06-13-2023, 06:01 PM)OldBob1938 Wrote: It will no longer send emails or ftp.

Can you be more specific? Are you getting compiler errors? Runtime errors? What do they say?

Also, what does your configuration of TIdSMTP (and TIdFTP?) look like? Especially in regards to authentication? Service providers do change their authentication requirements over time. And right now, a lot of service providers are switching to newer TLS versions, and/or to OAuth2, etc. So, it might just be that your code is simply outdated for your service provider's needs. Maybe they cut over to a new system at the beginning of June, and you didn't get your code ready in time.

(06-13-2023, 06:01 PM)OldBob1938 Wrote: My sending code is below and errors skip the first to Catch attempts.

As well they should, because Indy is written in Delphi not C++, so it will NEVER throw exceptions that are derived from C++'s std::exception class, so your catch statements for catching STL exceptions will NEVER be executed, only the final catch(...) will execute.

If you want to catch Delphi-style exceptions, you need to catch (descendants of) the Delphi RTL's Sysutils::Exception class instead, eg:

Code:
...
try
{
    gSMTP->Send(idMsg);
    MessageSent = true;
}
catch(const Sysutils::Exception& e)
{
    // specific handling for all exceptions extending Sysutils::Exception
    //std::wcerr << L"Error occurred: (" << const_cast<Sysutils::Exception&>(e).ClassName().c_str() << L") " << e.Message.c_str() << std::endl;
    BobMessage("Error occurred: (" + const_cast<Sysutils::Exception&>(e).ClassName() + ") " + e.Message);
    MessageSent = false;
    Close();
}
...

Reply
#3
Hi Remy

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. 

 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.

My code has not changed for over a year and has been working fine until early June.  

Your previous comment is probably the issue.
what does your configuration of TIdSMTP (and TIdFTP?) look like? Especially in regards to authentication? Service providers do change their authentication requirements over time. And right now, a lot of service providers are switching to newer TLS versions, and/or to OAuth2, etc. So, it might just be that your code is simply outdated for your service provider's needs. Maybe they cut over to a new system at the beginning of June, and you didn't get your code ready in time.  

I'm using libeay32.dll and ssleay32.dll  
gSMTP->AuthType  = satDefault;
gSMTP->IOHandler = IdSSLIOHandlerSocketOpenSSL1;
gSMTP->Host      = "smtp-relay.gmail.com";
gSMTP->Port      = 587;
gSMTP->Username  = "myusername";
gSMTP->Password  = "mypassword";           

gSMTP->MailAgent = "AISLA";
gSMTP->UseTLS    = utUseExplicitTLS;
gSMTP->PipeLine  = true;

// gSMTP->OnStatus  = gSMTPStatus;        //gSMTPStatus is unknown

IdSSLIOHandlerSocketOpenSSL1->Destination   = "smtp.gmail.com";
IdSSLIOHandlerSocketOpenSSL1->Host          = "smtp.gmail.com";
IdSSLIOHandlerSocketOpenSSL1->MaxLineAction     = maException;
IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Method   = sslvTLSv1;
IdSSLIOHandlerSocketOpenSSL1->SSLOptions->Mode    = sslmUnassigned;
IdSSLIOHandlerSocketOpenSSL1->SSLOptions->VerifyDepth = 0;t


I don't know if this is what you asked for re configuration.

Thanks for your help as always.

Bob
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)