Email Authentication – Gmail Blocking Mutt: Solutions and Fixes

authenticationemailimapmutt

When I try to log in to gmail with mutt, it flashes a quick Webalert with a url, something like accounts.gmail.com or something. It's too quick for me to see or copy it. Then it says Login failed.

Then I get an email from Gmail saying:

Google Account: sign-in attempt blocked

Hi Adam, 

We recently blocked a sign-in attempt to your Google Account [a...@gmail.com]. 

Sign in attempt details
Date & Time: Wednesday, December 10, 2014 11:55:21 PM UTC 
Location: Utah, USA 

If this wasn't you
Please review your Account Activity page at         https://security.google.com/settings/security/activity to see if anything looks suspicious.     Whoever tried to sign in to your account knows your password; we recommend that you change it right away. 

If this was you
You can switch to an app made by Google such as Gmail to access your account (recommended) or change your settings at https://www.google.com/settings/security/lesssecureapps so that your account is no longer protected by modern security standards. 

To learn more, see https://support.google.com/accounts/answer/6010255. 

Sincerely,
The Google Accounts team

I can go to the link and enable "Access for less secure apps" and then I can log in just fine, but is there a way to login with mutt without having to turn on this less secure option in Gmail?

Update:

I'm on mac os x Yosemite
When I run mutt -v, in the compile options, it does contain +USE_SSL_OPENSSL
I'm not using google 2-step verification
I'm not using an application specific password
Here are the messages that I get when I try to log in:

Reading imaps://imap.gmail.com:993/INBOX...
Looking up imap.gmail.com...
Connecting to imap.gmail.com...
TLSv1.2 connection using TLSv1/SSLv3 (ECDHE-RSA-AES128-GCM-SHA256)
Logging in...
[WEBALERT https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsm0P......

I found this answer, but it didn't work: https://stackoverflow.com/a/25209735/1665818

Best Answer

I finally got it to work by enabling Google 2-step verification and using an app-specific password for mutt.

More detail:

I enabled 2-step verification on my Google account, which means that when I log in to Google, I have to enter a pin number from either a text or from the Google Authenticator app.

Then I had to get an app-specific password for mutt. You can generate an app specific password here.

Then I used that app-specific password for logging into mutt instead of my normal password. And then I don't have to enter a pin number.

Related Question