Rank: Newbie
Groups: Registered
Joined: 5/6/2022(UTC)
Posts: 1
Location: Zaandam
We're using the AESendMail a few years now without problems.
Now gmail is changing their conditions and you can only send mail with OAuth2.
I've test it with the example project and works fine. But in my own project it will not work.
For the user I've created a form to get the accesstoken and refresktoken. This is saved in a database.
Then I create a message and send it to gmail:
Code:
procedure Tfo3EmailOpstellen.SendGEmail;
const ConnectSSLAuto = 1;
var body_html : string;
begin
Oauth := TOauthWrapper.Create;
oSmtp := TMail.Create(nil);
try
Oauth.InitGoogleSmtpProvider;
oSmtp.LicenseCode := 'xxxxxxxx';
// Set Asynchronous mode
oSmtp.Asynchronous := 1;
Oauth.accesstoken := email.EmailAccountNil.GMail_AccessToken; // from database
Oauth.refreshtoken := email.EmailAccountNil.GMail_RefreshToken; // from database
if not DoOauth() then
begin
showmessage('Failed to request/refresh access token!');
exit;
end;
oSmtp.Charset := 'utf-8';
oSmtp.FromAddr := email.EmailAccountNil.SMTP_Inlognaam;
oSmtp.ReplyTo := email.EmailAccountNil.SMTP_Inlognaam;
// Add recipient's
oSmtp.ClearRecipient();
oSmtp.AddRecipientEx(trim(email.EmailAdresNaarOverflow), 0);
// Set subject
oSmtp.Subject := email.Onderwerp;
// Using HTML FORMAT to send mail
oSmtp.BodyFormat := 1;
body_html := email.AntwoordHtmlOverflow2;
oSmtp.ImportHtml( body_html, GetCurrentDir());
oSmtp.ServerAddr := email.EmailAccountNil.SMTP_Servernaam;
oSmtp.ServerPort := 587; //ports[lstPort.ItemIndex];
oSmtp.Protocol := 0; //SMTP protocol
oSmtp.UserName := Oauth.UserEmail;
oSmtp.Password := Oauth.AccessToken;
oSmtp.AuthType := 5; // XOAUTH2;
// Use SSL/TLS based on server port.
oSmtp.ConnectType := ConnectSSLAuto;
oSmtp.SendMail();
if oSmtp.GetLastErrDescription() <>'' then
ShowNBMessage('Fout : ' + oSmtp.GetLastErrDescription())
else
ShowNBMessage('Mail verstuurd');
finally
Oauth.free;
oSMTP.free;
end;
end;
Everytime a mail will be sent, the SMTP will be created. The mail is sent but is not recieved ever. Sendmail() gives no error back.
If I use this piece of code with geeting an accesscode the mail is sent and received succesfully. But then I have to login to gmail everytime when sending mail.
Is it possible to send a mail with a accesskey without logged in gmail?
I created my project in Delphi 10.4
with kind regards,
John Kuiper.
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,153
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
Hi, you used asynchronous mode, you cannot get the result directly from the GetLastErrDescription like this way.
Please refer to the sample project in EASendMail, you should use OnError event to catch the error information.
https://www.emailarchite...il/kb/delphi.aspx?cat=11
Rank: Newbie
Groups: Registered
Joined: 4/19/2020(UTC)
Posts: 1
Location: San Jose, CA
Hi, Did you every resolve your problem? I just started your a relay service for the customer. Gmail is getting worst and worst to deal with. Thanks, Rick Kamp
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,153
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
Originally Posted by: rkamp2 Hi, Did you every resolve your problem? I just started your a relay service for the customer. Gmail is getting worst and worst to deal with. Thanks, Rick Kamp
If you have any problem, please contact our technical support email address directly:
https://www.emailarchitect.net/contact.aspx
Forum Jump
EmailArchitect Support
Email Component Development
- EASendMail SMTP Component - .NET Version
- EASendMail SMTP Component - Windows Store Apps
- EASendMail SMTP ActiveX Object
- EAGetMail POP3 & IMAP4 Component - .NET Version
- EAGetMail POP3 & IMAP4 ActiveX Object
Exchange Server and IIS SMTP Plugin
- DomanKeys/DKIM for Exchange Server and IIS SMTP
- Disclaimer and S/MIME for Exchange Server and IIS
EmailArchitect Email Server
- EmailArchitect Email Server (General)
- EmailArchitect Email Server Development
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.