[SOLVED]xmailer not mailing via smtp.gmail.com, only via other servers
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
mirce.vladimirov · 2021-03-22 21:10
Hi everyone,
I'm using windows 10, and my mailing application wont send mail unless
i send it thru non-gmail smtp server.
Here is my code :
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i uses .....
XMailer ;procedure TForm1.prakjaj_gmail;var Mail: TSendMail;begin
Mail := TSendMail.Create; try try Mail.Sender :=
'myaccount@gmail.com';
Mail.Receivers.Add('recipient@somemailserver.com');
Mail.Subject := 'this is the subject';
mail.ContentType:=ctTextHTML; Mail.Message.Add('Hello
world
this is another line in the body');
Mail.Smtp.UserName := 'myaccount@gmail.com';
Mail.Smtp.Password := 'mypwd' ; Mail.Smtp.Host :=
'smtp.gmail.com'; Mail.Smtp.Port := '587'; Mail.Smtp.SSL
:= True; //Mail.Smtp.FullSSL:=true;
Mail.Smtp.TLS:=true; Mail.Send; except on E:
Exception do ShowMessage(E.Message); end; finally
end; Mail.Free;end;
I am getting an exception error, see the attachment.
It's not an issue of openssl's DLL libraries because I am able to send
mail via other SMTP servers, am I right?
----------------------------------------------------------------------
sstvmaster · 2021-03-22 22:27
gmail uses OAuth2! ->
https://developers.google.com/gmail/api/auth/about-auth
----------------------------------------------------------------------
Gustavo 'Gus' Carreno · 2021-03-22 22:55
Hi sstvmaster and mirce,
Quote from: sstvmaster on March 22, 2021, 11:27:15 pmgmail uses
OAuth2! -> https://developers.google.com/gmail/api/auth/about-auth
I can be on the wrong here, but that is if you're sending mail via
Google's API, not SMTP.
For SMTP, and again I'm pulling this from very bad memory, I think
they use some kind of encryption that I completely forgot.
From a very quick Google this article (Dated 2 Feb 2021) mentions that
you need BOTH TLS and SSL.
It claims that SSL port is 465 and TLS port is 587.
Looking at your code, I'm guessing that all that's missing is the
different port numbers?
Hope that helps!!
Cheers,
Gus
----------------------------------------------------------------------
mirce.vladimirov · 2021-03-23 09:37
Quote from: gcarreno on March 22, 2021, 11:55:54 pmFrom a very quick
Google this article (Dated 2 Feb 2021) mentions that you need BOTH TLS
and SSL.
It claims that SSL port is 465 and TLS port is 587.
Looking at your code, I'm guessing that all that's missing is the
different port numbers?
Hope that helps!!
Cheers,
Gus
I know that both SSL and TLS are used, the code that I've posted
confirms that.
How can I set the SSL's and TLS's different port numbers? All I have
used so far was :
Code: [Select] Mail.Smtp.Port := '587';
While usage of SSL or TLS is thru a boolean :
Code: [Select] Mail.Smtp.SSL := True;
//Mail.Smtp.FullSSL:=true;
Mail.Smtp.TLS:=true;
----------------------------------------------------------------------
trev · 2021-03-23 10:12
If you're only sending via Gmail, then use TLS on port 587.
----------------------------------------------------------------------
Gustavo 'Gus' Carreno · 2021-03-23 23:36
Hey Mirce,
I'm really sorry I can't be of more help. I did say I was quite
ignorant on the subject and was just going on off that quick Google
search I did.
Another humble suggestion would be for you to have a gander ate the
TSendMail code and see if you can deduce where to set the TLS port to
587.
Again really sorry for the limited help I can provide.
Cheers,
Gus
----------------------------------------------------------------------
mirce.vladimirov · 2021-03-29 11:39
Solved.
Everything is actualy fine with the Xmailer, it was an issue of a
gmail-specific setting.
Gmail has a special setting :
1. Log in thru admin.google.com
2. find the setting called "Less secure app access"
3. Set it to "on"
That's it.
Thank you friends.
----------------------------------------------------------------------
Remy Lebeau · 2021-03-29 16:02
Quote from: gcarreno on March 22, 2021, 11:55:54 pmI can be on the
wrong here, but that is if you're sending mail via Google's API, not
SMTP.
GMail uses OAuth2 authentication on SMTP, too. If you have multi-
factor authentication enabled, you can instead configure an app-
specific password in Gmail's settings, then you don't need OAuth2.
----------------------------------------------------------------------
Remy Lebeau · 2021-03-29 16:03
Quote from: mirce.vladimirov on March 29, 2021, 01:39:36 pmGmail has a
special setting :
1. Log in thru admin.google.com
2. find the setting called "Less secure app access"
3. Set it to "on"
Absolutely do not turn that on! Use an app-specific password instead,
then you are not compromising the account's security for the sake of
one app.