Sending email via SMTP using gmail lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Nicola Gorlandi · 2022-05-13 11:58 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 · 2022-05-13 16:18 Quote from: Nicola Gorlandi on May 13, 2022, 01:58:28 pmI 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. ---------------------------------------------------------------------- Thaddy · 2022-05-13 16:53 It is also included in FPC. ---------------------------------------------------------------------- dseligo · 2022-05-13 18:51 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 · 2022-05-14 10:18 Many thanks to all for your suggestions ---------------------------------------------------------------------- Remy Lebeau · 2022-05-15 01:28 Quote from: dseligo on May 13, 2022, 08:51:05 pmIf 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. ---------------------------------------------------------------------- Nicola Gorlandi · 2022-07-03 08:47 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 · 2022-07-03 09:00 https://forum.lazarus.freepascal.org/index.php/topic,59718.0.html ---------------------------------------------------------------------- rvk · 2022-07-03 09:03 Quote from: Nicola Gorlandi on July 03, 2022, 10:47:23 amUp 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.