Recent

Author Topic: Sending email via SMTP using gmail  (Read 830 times)

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 113
Sending email via SMTP using gmail
« on: May 13, 2022, 01:58:28 pm »
Hi all,
I read that Google will change the way to login to its SMTP server introducing the Two-Factor Authentication (2FA).

It is possibile in Lazarus to send email with this authentication ?

In case there are library avaiable (as Xmailer for example) ?

Thanks,

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1144
    • Lebeau Software
Re: Sending email via SMTP using gmail
« Reply #1 on: May 13, 2022, 06:18:09 pm »
I read that Google will change the way to login to its SMTP server introducing the Two-Factor Authentication (2FA).

Gmail has supported 2FA via OAuth 1.0/2.0 for a long while now.  This is nothing new.  What is new is that they are simply turning off access to "less secure apps" by default, but you can turn it back on if you still need it.  Though, you really should use software that supports OAuth 2.0, that is the preferred method going forward.  But, using app-specific passwords still works, too.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Thaddy

  • Hero Member
  • *****
  • Posts: 11903
Re: Sending email via SMTP using gmail
« Reply #2 on: May 13, 2022, 06:53:18 pm »
It is also included in FPC.
Black themes should be banned.

dseligo

  • Hero Member
  • *****
  • Posts: 708
Re: Sending email via SMTP using gmail
« Reply #3 on: May 13, 2022, 08:51:05 pm »
If you have 2-Step Verification turned on then you have to set App password for each application (you can't use main Google password).
You go to your Google account (not Settings in Gmail), Security and in the 'Signing into Google' panel you have 'App passwords' option.

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 113
Re: Sending email via SMTP using gmail
« Reply #4 on: May 14, 2022, 12:18:01 pm »
Many thanks to all for your suggestions

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1144
    • Lebeau Software
Re: Sending email via SMTP using gmail
« Reply #5 on: May 15, 2022, 03:28:02 am »
If you have 2-Step Verification turned on then you have to set App password for each application (you can't use main Google password).

OAuth is Google's preferred way.  The user logs in with their normal password, and are then given a token that is used during authentication.  Using an app-specific password is only needed for software that doesn't support OAuth.  Most modern email programs do support OAuth when accessing Gmail.  But lets say you are using an SMTP client written in Delphi/FreePascal, then you might need an app-password unless the client is updated to use OAuth instead.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 113
Re: Sending email via SMTP using gmail
« Reply #6 on: July 03, 2022, 10:47:23 am »
Hi to all,

Up to now gmail do not accept anymore to switch off less secure app. Could you please give me some information about how to implement OAUTh for sendi email with gmail ? Many thanks

paweld

  • Sr. Member
  • ****
  • Posts: 456
Best regards
paweld

rvk

  • Hero Member
  • *****
  • Posts: 4947
Re: Sending email via SMTP using gmail
« Reply #8 on: July 03, 2022, 11:03:16 am »
Up to now gmail do not accept anymore to switch off less secure app. Could you please give me some information about how to implement OAUTh for sendi email with gmail ?
You don't really need OAuth2 for sending mail via Gmail.
You can just use app passwords.

First enable two factor authentication on your account and create an new App Password here
https://myaccount.google.com/security

Use that App Password instead of your normal password and it should work without any modifications.

 

TinyPortal © 2005-2018