I have the following in my init.el:

(require 'smtpmail)
(setq message-send-mail-function 'smtpmail-send-it
     smtpmail-stream-type 'starttls
     smtpmail-default-smtp-server "smtp.gmail.com"
     smtpmail-auth-credentials (expand-file-name "~/.authinfo.gpg")
     smtpmail-smtp-server "smtp.gmail.com"
     smtpmail-smtp-service 587)

.authinfo decrypts fine and contains:

machine smtp.gmail.com login ***1 password ***2 port 465

Where ***1 and ***2 are my username and password respectively.

But upon sending mail from mu4e I am still prompted for credentials.

If I enter the credentials at the prompt sending works.

What am I missing?


The auth-source lookup done by smtpmail uses the smtpmail-smtp-service port as well, so you need to specify '587' in .authinfo.gpg (although personally I advocate for using port 465 and a stream-type of 'tls).

  • Thank you very much. Why do you recommend tls/465 and will that work with the gmail servers? – mac Feb 10 at 12:16
  • Yes it works with gmail. The reason I recommend it is that when using direct tls, your connection is always encrypted. When using 587/starttls, the connection starts out unencrypted and is then 'upgraded' to encrypted, which leaves a window for your connection to be read, or even for the upgrading to be disabled (by filtering out the announcement of STARTTLS capability from the remote server). – rpluim Feb 10 at 12:23
  • Great feedback, thanks. – mac Feb 10 at 12:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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