1

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?

2 Answers 2

3

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).

5
  • Thank you very much. Why do you recommend tls/465 and will that work with the gmail servers?
    – mac
    Commented Feb 10, 2019 at 12:16
  • 1
    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
    Commented Feb 10, 2019 at 12:23
  • Great feedback, thanks.
    – mac
    Commented Feb 10, 2019 at 12:49
  • This thread suggests using port 25, which I understand is for establishing the session keys. Both ports 465 and 587 prompt me for my password. Do you not get prompted for a password when using ports 465 and 587?
    – emonigma
    Commented Mar 12, 2019 at 11:44
  • There is no establishment of 'session keys' with SMTP. You connect to a port, using either TCP or TLS, and the remote server can then choose to prompt you for authentication.
    – rpluim
    Commented Mar 12, 2019 at 12:52
0

I was facing the same problem and I had consistent port numbers. It seems smtpmail-auth-credentials is no longer needed (since Emacs 24.1). Keeping the information in ~/.authinfo.gpg and removing the line from your init file will work. (Based on xuchunyang's comment here)

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.