Google disabled access to less secure apps - python

With google having disabled the access to enable access to less secure apps can anyone suggest ways in which I can send mails using flask-mail? It has to be disabled in the mail account I'm using to send mails using flask-mail.

If your problem is about google security you can use app password instead of your account password in MAIL_PASSWORD configuration, To do that you should enable 2-step verification in your Google Account and then use app password,
So go to your Google Account,
Security
Signing in to Google
Enable 2-step verification
App password
Make app password and use it as your MAIL_PASSWORD
In link below you can see other options
https://support.google.com/accounts/answer/6010255?hl=en&utm_source=google-account&utm_medium=profile-less-secure-apps-card

I had a similar problem using sendmail and ESMTP with Google Mail,
and the excellent 'sender_based_routing' patch from:
http://faculty.cs.niu.edu/~rickert/cf/
which allows sendmail to choose a different relay based on
email 'From:' headers; using my MS-365 corporate email selects
smtp.outlook365.com , while using my personal email selects
smtp.google.com.
Because I am out of mobile phone coverage while at home, I cannot
enable 2-Factor authentication or use an App Token, which requires
2-factor authentication and the ability to receive SMS; my
mobile phone package does not include SMS-over-WiFi, and
Google's 2-factor Auth SMS messages are not sent over Google Chat SMS.
The only workaround I have found is to open a new Google WorkSpaces
email account, then you can enable the SMTP relay feature, and
sending email with sendmail + ESMTP then works again.
Google has thus doubled its revenue stream from me; and since I must copy every message sent by my new account to my old one,
it has doubled my storage requirements, that I pay for.
Clever Google! Never neglects an opportunity to squeeze more
profit from its users.
Anyway, paying for 2 email accounts in order to send emails is
vastly preferable to be being forced to use the horrible GMail
GUI - I can use MA/GNUS Emacs to send mails - definitely worth it.
The best long term solution, which I will do as soon as I can,
is setup one's own Email server , and scrap use of Google altogether - I wish I was in a position to do this, as soon as
I am I will - it requires a static IP and an always-on server.

so you need to set up the App Password from setting.
This video shows how to set up App Password = link.
setps:
1. Manage your Google Account
2. Goto the Security. on left side
3.At security->Signing in to Google
1 first need on 2-setp-verfication.
2 then click App Password.then select app and device.
for me app=Mail.
device=Windows Compter.
3 A password is genrated. copy the password. It only show one time
4 used this password to login.

Note: Before proceeding please enable 2 factor authentication.
Less secure apps (https://myaccount.google.com/u/0/lesssecureapps) is no longer available.
We can use apppasswords feature provided by google via following link
https://myaccount.google.com/u/0/apppasswords
Check below image for reference, Use 16 digit code provided by google in-place of password.

Related

How do I to give my web project access to my Gmail account?

I am trying to adapt to Google's change in smtp policy on 5.30.22 that prevents 3P apps to have access to gmail account. I want to give my web project hosted on heroku access to be able to login programatically to my gmail account. I checked out some posts including this one, but I'm just not seeing what is expected in my settings.
In that gmail account, I go to Security -> Less secure app access and confirmed it is, in fact, no longer available. I saw nothing else in Security that seemed relevant.
Then, I try Data & Privacy -> Data from apps and services you use -> Apps & Services -> Third-Party Apps With Account Access. Clicking on that takes me to
Apps with access to your account, where I see You haven’t given any apps or services permission to access your Google Account. Learn more (<-- link to https://support.google.com/accounts/answer/3466521?hl=en). That link brings me to Manage your account permissions -> Manage third-party apps & services with access to your account.
I then go to Review what a third party can access. Steps for that are:
Go to the Security section of your Google Account.
Under “Third-party apps with account access,” select Manage third-party access.
Select the app or service you want to review.
...but in step #2, there is no Third-party apps with account access or Manage third-party access link/section in my security page.
How do I add an app I'm working on to that list?
UPDATE - I saw https://support.google.com/accounts/answer/112802?hl=en&ref_topic=7188760, which is "Use your Google Account to sign in to other apps or services". Is this what I need? It says to:
Go to an app or service you trust.
On the sign in page, select Sign in with Google, Log in with Google, or Join with Google.
I go to my app (hosted on heroku), but the "Sign in with Google" option is not there.
Due to the removal of Less secure apps & your Google Account you can not use a users login and password to access googles smtp server.
You have two sevral options.
Switch to using the gmail api and authorize your application using Oauth2 and store a refresh token. Make sure to set your app to prodctuion or the refresh token will expire after seven days.
Use xoauth2 with your request to the smtp server. You will then need to use Oauth2 to authorize the application and store a refresh token. Make sure to set your app to production or the refresh token will expire after seven days.
If you have 2fa enabled on that account then you can create an apps password. Sign in with App Passwords Once you have created this password you can then use it in place of the actual password in your code.

What's solution for sending emails from python while gmail " the less secure apps " is not enabled anymore

I recently was using smtp library for sending emails from gmail account but recently it stopped working after research I found out the google can not let you enable the less secure app anymore . So is there any workaround this ?
If you want to continue using Gmail SMTP, you can set it up by setting an app password. An app password works like an alternate password for your account. It can only be used by the applications you share it with, so it’s more secure than sharing your primary password.
Here's how you can set it up: https://support.google.com/accounts/answer/185833?hl=en

I encounter an AUTHENTICATIONFAILED error when connecting to email with imaplib library

How can I connect to imaplib library without encountering AUTHENTICATIONFAILE error !?
My Gmail inbox shows me a serious security alert (login attempt blocked) when logging in through the web browser.
IMAP_SERVER = 'imap.gmail.com'
USERNAME = '******#gmail.com'
PASSWORD = '******'
client = imaplib.IMAP4_SSL(IMAP_SERVER)
client.login(USERNAME, PASSWORD)
This is most likely gmail blocking "less secure apps" from connecting to your account. This blocking is enabled, by default.
From a google support page:
You can block sign-in attempts from some apps or devices that are less secure. Apps that are less secure don't use modern security standards, such as OAuth. Using apps and devices that don’t use modern security standards increases the risk of accounts being compromised. Blocking these apps and devices helps keep your users and data safe.
If you would like to turn on access to less secure apps (which will make your account more vulnerable to being attacked), then you can follow these steps:
Sign into your google account normally. (https://myaccount.google.com/)
Once signed in, go to the "Security" page.
Scroll down until you see a window with "Less secure app access". If you want to access your email using python code like you posted, this needs to be turned on.
Personally, I think this is acceptable on a throwaway/testing account but I would never do this to my main/personal account or any account involving communicating with clients.
In fact, take a look at this page: https://developers.google.com/gmail/api/quickstart/python
Gmail has a dedicated API for connecting to your google mail account. Their api implements proper security measures which means you won't need to enable less secure app access... protecting your account!

Google Appengine not signing emails with DKIM code

Am confused why emails sent by my appengine app are not being signed with DKIM.
Enabled DKIM signing on Google Apps dashboard. Confirmed that my domain is "Authenticating email"
Have setup DNS TXT record using the values indicated in the apps domain. Have confirmed, using 3rd party validation tool, that the DNS is correct. Also, I assume that having a green-light indicator for authenticating email in my Google Apps domain means this record has been validated by Google Apps.
Email-send is being triggered by a click by a user browsing my application via my custom url. The custom url matches the domain for the return address of the sender. The sender return address is an owner of the account.
As far as I know, these are the requirements for emails to be signed automatically. Yet, alas, they are not being signed. Any help or ideas will be greatly appreciated. Thanks -
How long ago did you create your DNS TXT record? Since DKIM is a DNS controlled service, and DNS often takes up to days to propagate across the Internet, you may need to wait for that to happen before Google will recognize it as valid.

Connecting to Google app email servers in Python to send from an alias

I'm looking to send many emails via Python and would like to connect to Google's email servers to send it from my company email address (it's for work). I've got working code for sending the email through the old company email (user#work.com) which is our login, but can't figure out how to send it through the alias (user#betterdomain.com) we use frequently.
Long story short, logging in with my regular Google Apps account won't do and I need to sign in with an alias (nickname) instead. Alternatively, I can sign with the regular account (user#work.com) but send via a different email (user#betterdomain.com).
Working in python and pretty new to programming, but am a good listener! (It's like this question: Google Apps - Send email from a nickname but in Python).
If I understand properly, what you are trying to do is get the Google App Engine send an email on behalf of logged in user, who is using his Google Apps Account name to login. Is it right?
In that case, the mail API for App Engine informs about the mail.send_mail() wherein From: address can be the current user if signed in with Google Accounts. If this is not what you are looking for, some clarification might be required.

Categories