Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending email through Gmail
(07-16-2018, 09:21 PM)rlebeau Wrote:
(07-16-2018, 08:19 PM)jjeffman Wrote: Which are the correct settings to enable Indy10 to send emails using Gmail's SMTP?

You need to connect to '' on port 587, and have the UseTLS property set to utUseExplicitlTLS (be aware that the UseTLS setter can change the Port property, so make sure you are actually connecting to the correct port!).

Also, Indy does not yet support OAuth authentication over SASL, so if you have multi-factor authentication enabled in your Gmail account, you need to generate an application-specific password in your Gmail security settings, and then you can use that password with Indy, using your gmail email address as the username.

Thank you very much for answering me.

I have checked the sender gmail account and it does not require a two steps login procedure.

   emailStatus->Lines->Add("About to connect using:");
   emailStatus->Lines->Add("username: " + SMTP->emailSender->Username);
   emailStatus->Lines->Add("password: " + SMTP->emailSender->Password);
   emailStatus->Lines->Add("SMTP: " + SMTP->emailSender->Host);
   emailStatus->Lines->Add("Porta: " + IntToStr(SMTP->emailSender->Port) );
   emailStatus->Lines->Add("UseTLS: "+ SMTP->GetTLSMode() );
   emailStatus->Lines->Add("TLSMethod: "+SMTP->GetTLSMethod());

   //send mail
     //SMTP->emailSender->ConnectTimeout = 120;
   catch( Exception *E){
     emailStatus->Lines->Add( "ERROR: " + E->Message);

The code above add the lines below to a TMemo :

Quote:Indy10 version:
Sending email to:
About to connect using:
username: <recipient>
password: ********
Porta: 587
UseTLS: utNoTLSSupport
TLSMethod: sslvTLSv1
Resolving hostname

Connecting to

SMTP Connected
ERROR: Must issue a STARTTLS command first. 49-v6sm947685qtu.0 - gsmtp

SMTP Disconnected

No matter the value I set to the SSLOptions method the error message is the same. All the dll modules has been loaded unless I have called the function outside the correct position.

I have just changed some code positions to assure that Port and UseTLS properties have the correct value. The error has changed to :

rY3Dizvx9JK2UC-zyHlRi9VYUyUdD84xr6LeX1qRzZDjbFHtyi> Please log in via
your web browser and then try again."

What am I doing wrong?

After going to the limk Gmail sent in the error message and having changed the security options I have succeeded on snding emails through Gmail SMTP.

Thank you very much.

Best regards.

Jayme Jeffman

Messages In This Thread
Sending email through Gmail - by jjeffman - 07-16-2018, 08:19 PM
RE: Sending email through Gmail - by rlebeau - 07-16-2018, 09:21 PM
RE: Sending email through Gmail - by jjeffman - 07-17-2018, 03:05 PM
RE: Sending email through Gmail - by rlebeau - 07-17-2018, 05:38 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)