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?

mac
  • 225
  • 1
  • 13

2 Answers2

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

rpluim
  • 4,605
  • 8
  • 22
  • Thank you very much. Why do you recommend tls/465 and will that work with the gmail servers? – mac Feb 10 '19 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 Feb 10 '19 at 12:23
  • Great feedback, thanks. – mac Feb 10 '19 at 12:49
  • [This thread](https://emacs.stackexchange.com/questions/46257/sending-email-fails-with-process-smtpmail-not-running?noredirect=1#comment71150_46257) 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? – miguelmorin Mar 12 '19 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 Mar 12 '19 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)

swaroop
  • 1
  • 1