Python cannot send email from gmail account with smtp - python-3.x

I used gmail account to send email notification when my script fails. Since May 30, 2022, Gmail stops supporting access over Less secure app access
This setting is no longer available.
From Google support:
To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.
I am receiving python error even my user and password is OK (tested by logging to my account):
Authentication error. Wrong user or password.
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials u2-20020a1709061da200b0072f42ca2934sm7507815ejh.148 - gsmtp')
What is the best way how to use google account for notification emails or is there better way or tool how to be notified?

When you want to send email over Gmail SMTP, google enable you to set up App password. You have to have set up 2-Step verification in your google account. Once 16 digit password are generated, you just replace password for login (username is your email address, that does not change).
Sources:
Google: Sign in with App Passwords
Stackoverflow: What's solution for sending emails from python while gmail " the less secure apps " is not enabled anymore

Related

How to use Nodemailer with Google?

Hello I made a NodeJs backend and I implemented nodemailer. The only issue is I get the error with Invalid Login, because I don't have less secure apps turned on. I know, but I went to google and I clicked on the less secure app section and this is what I get
This setting is no longer available. Learn more
Does anyone solved the error different way and is able to send emails?
When you want to send email over Gmail SMTP, google enable you to set up App password. You have to have set up 2-Step verification in your google account. Once 16 digit password are generated, you just replace password for login (username is your email address, that does not change).
Sources:
Google: Sign in with App Passwords

can curl no longer send emails using gmail accounts?

I've been using the following to test that html email templates come through formatted correctly in different clients:
curl --ssl-reqd --url 'smtps://smtp.gmail.com:465' --user '{EMAIL}#gmail.com:{PASSWORD}' --mail-from '{EMAIL}#gmail.com' --mail-rcpt '{EMAIL}#gmail.com' --upload-file {FILE}
And all of a sudden I'm getting "curl: (67) Login denied" - the login details are definitely correct and nothing's changed on my end. My guess is that google is now blocking non SSO email logins?
Don't know if will solve your problem, but if you have enabled 2-Step Verification in your Google account, you have to create some app password
You will have to make a new 16 digits password specific for this application and simply change the account password to this new secure app password. Now you can create one password for each app. It will keep your account password safe and manage app passwords separately.
Login to your account to create it:
https://myaccount.google.com/apppasswords
You must enable the 2-Step Verification (https://myaccount.google.com/signinoptions/two-step-verification) to access this feature.
To help keep your account secure, from May 30, 2022, ​​Google no
longer supports the use of third-party apps or devices which ask you
to sign in to your Google Account using only your username and
password.
https://support.google.com/accounts/answer/6010255

How to send form data to Gmail without using nodemailer

I was trying to get form data to my gmail account so I get to know about 'nodemailer' package but the problem is that it is asking for my gmail password also I have to make my gmail account less secure for this.
Is there any way to get mail without my password?
Use an 'App Password' for this purpose. This is "a 16-digit passcode that gives a less secure app or device permission to access your Google Account". See https://support.google.com/accounts/answer/185833?hl=en

Invalid login: 535-5.7.8 Username and Password not accepted

while sending mail using modemailer with only few accounts it is working fine, but with some accounts, even though the credentials are correct, it is giving "Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials 3sm51852778pfg.186 - gsmtp"
Solution 1: It's the gmail security for less secure apps. Also a quick solution will be to turn off the access Allow less secure apps
Solution 2: Best way will be to work with 2-Step verification 2-Step Verification
Solution post May 2022:
The issue you are having is related to googles remove Less secure apps & your Google Account setting from our google accounts. Less secure apps was what enabled us to use our google login and passwords with their smtp server.
In order to use it now you must enable 2fa on your google account and configure an apps password. You can then use the apps password in place of your actual google password to connect to the smtp server.
Quick fix for SMTP username and password not accepted error

Azure Multifactor Authentication how to do Passcode Verification on sign in page

I want to integrate Multi-Factor Authentication into my custom built, Azure Hosted website.
I want the user to get an OTP (One Time Password) over SMS and then enter that OTP on the Sign-in page.
How am I supposed to verify the OTP entered by the user on Sign-in page? I was unable to find anything related to that in the SDK and online documentation.
SDK documentation on MSDN http://msdn.microsoft.com/en-us/library/dn422962.aspx tells us that:
"Text messages. Windows Azure Multi-Factor Authentication can send an SMS text message with a one-time passcode to any mobile phone. To complete the sign-in process, the user is prompted to reply with the passcode or passcode and PIN, or to enter the passcode on an application sign-in screen."
but unfortunately it doesn't tell how the sent passcode is verified, either via the SDK itself or some other way.
It's really confusing coz one would think the received token needs to be entered on the comp, but apparently the SMS needs to be replied to the SMS sender. All the docs on the net shows differently, they all show some second login screen for the token to be entered:
http://www2.warwick.ac.uk/services/its/servicessupport/networkservices/vpn/itsvpn/
But no, it's not quite how it works with Azure.
For whatever reason SMS didn't work for me. I did receive the SMSes but even after I replied to the sender number, it still wouldn't authenticate me. Also, it'd have increased the costs even further so I just sticked with the automated phone call.
Now I use it to authenticate VPN users on our Cisco ASA firewall. The authentication process goes like this:
user clicks on connect in the VPN client
user enters user + password, then clicks login, now the client is waiting for a response
credentials are sent to ASA, which asks the Multi-Factor Authentication Server if they're ok
the MFAS verifies that they're ok so it tells Azure to call the user's phone number
user receives call, presses the # key (that's the "standard" method, there's also a PIN method), then Azure hangs up the call and tells the MFAS that it can proceed
MFAS tells the ASA that the user's authenticated
client exits the waiting state and logs in

Resources