1

Q: how can I use a Gmail app password with smtp?

Google recently disabled the "less secure apps" option for Gmail, so I went ahead and created an app password so I could continue to access my Gmail account from the comfort of Emacs (mu4e + offlineimap).

offlineimap (and therefore mu4e) is able to access my account when using the app password I generated, so that part is working. However, I cannot send any messages. Every time I try, I get an error message that reads:

https://support.google.com/mail/?p=InvalidSecondFactor i20-20020a05620a249400b006a6ce613c7csm10357803qkn.89 - gsmtp in response to AUTH

(Yes, I have turned on 2-factor authentication as required to generate an app password.)

I have updated my smtp credentials with:

(setq smtpmail-auth-credentials
      '(("smtp.gmail.com"
         587 
         "[email protected]"
         "MY_NEW_APP_PASSWORD")))

What am I missing here?

1 Answer 1

1

Here's what I have, hopefully it will help you. Works for sending via C-x m or the gnus interface, and I've had it set up for several months.

~/.emacs:

(custom-set-variables
 '(send-mail-function 'smtpmail-send-it)
 '(smtpmail-smtp-server "smtp.gmail.com")
 '(smtpmail-smtp-service 587))

~/.authinfo:

machine smtp.gmail.com login [email protected] password MY_APP_PASSWORD
1
  • Yes, that works. I wish I knew why it works with the .authinfo file rather than entering the password directly in smtp-auth-credentials. (Yes .authinfo is more secure when using gpg, but I'm mainly curious why inputting it directly failed.) At any rate, thank you!
    – Dan
    Commented Jun 13, 2022 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.