I followed this guide to set up IMAP email with Emacs, mu, and mu4e. I can pull email and view it in mu4e alright, but I can't seem to send email. I press C for Compose, edit the email, then C-c C-c to send, and I get Process smtpmail not running in the mini-buffer window.

My SMTP configuration in ~/.emacs is:

 message-send-mail-function   'smtpmail-send-it
 user-mail-address "name@domain.tld"
 smtpmail-default-smtp-server "smtp.office365.com"
 smtpmail-smtp-server         "smtp.office365.com"
 smtp-mail-service 587
 smtpmail-local-domain        "name@domain.tld")

I haven't found any pointers to this problem. Am I missing something obvious?

  • perhaps : message-send-mail-function 'smtpmail-send-it ? – manandearth Nov 27 '18 at 17:24
  • Isn't that the second line of my code? – miguelmorin Nov 27 '18 at 19:04
  • it is... you are right . what about a smtpmail-stream-type value 'starttls or other? – manandearth Nov 27 '18 at 20:18
  • That does work, yes! It prompts me for username and password and I get Sending failed: ... Authentication unsuccessful [domain.domain.PROD.OUTLOOK.COM] in response to [random characters]. I tried setting (setq smtpmail-auth-credentials '(("smtp.office365.com" 25 "username@domain.com" "password"))) as in this EmacsWiki and it still prompts me for the password. It does the same with 587 instead of 25. How can I set the credentials? – miguelmorin Nov 30 '18 at 11:52
  • That should be in your .offlineimaprc file. – manandearth Nov 30 '18 at 12:30

Check the IMAP settings of the email provider. Office365, for example, has these settings under Settings > Your app settings > Mail > Mail > Accounts > POP and IMAP:

SMTP setting

Server name: smtp.office365.com

Port: 587

Encryption method: STARTTLS

Therefore, adding this line in your ~/.emacs should work:

(setq smtpmail-stream-type 'starttls)

You need to specify your credentials for SMTP in addition to those for IMAP (which would be in ~/.offlineimaprc, for example). You can give your credentials in the mini-buffer during the first authentication, or you can save this text in ~/.authinfo:

machine smtp.office365.com login username@domain.com port 25 password XYZ

Notice the use of port 25 (SMTP without TLS) for authentication, and the use of port 587 (SMTP with TLS) for sending mail after authentication.

For password protection look at .netrc , or GPG

  • That's not the way SMTP AUTH works: you authenticate and send using the same port, in this case 587. (Direct TLS to port 465 would be even better, but maybe Office365 doesn't support that). – rpluim Dec 17 '18 at 8:41
  • @rpluim That was my edit to @manandearth's answer because I could not make it work by changing port 25 to port 587. I just tested again: replacing 25 with 587 or 465 results in a prompt SMTP user name for smtp.office365.com (default username):. What are your settings? – miguelmorin Sep 14 at 16:01

Add these into your init file (e.g. ~/.emacs):

 user-mail-address "email@hotmail.com"
 message-send-mail-function   'smtpmail-send-it
 smtpmail-smtp-server         "smtp.office365.com"
 smtpmail-stream-type 'starttls
 smtpmail-starttls-credentials '(("smtp.office365.com" 587 nil nil))
 smtpmail-auth-credentials '(expand-file-name "~/.authinfo.gpg")

I use spacemacs, so you might want to change these lines. Change your ~/.authinfo file like this

machine smtp.office365.com login email@hotmail.com port 587 password "pass"
machine outlook.office365.com login "email" port 993 password "pass"

Also, type this into terminal

gpg -c .authinfo
This protects your files with GPG. It will ask for a password, just enter anything.

  • Good answer that includes GPG and password file encryption. – miguelmorin Sep 14 at 16:29
  • Do you use the same password file for retrieving and sending mail? Can you point me to Emacs settings to configure credentials for POP3? – miguelmorin Sep 14 at 16:29
  • With port 587 in the ~/.authinfo first line for SMTP, I get prompted: SMTP user name for smtp.office365.com (default email): and then SMTP password for email@smtp.office365.com:. I solved it by replacing port 587 with port 25 but I understand from @rpluim's comment above that it's not how SMTP AUTH works. Do you have an idea or should I ask a separate question? – miguelmorin Sep 15 at 7:48
  • Which version of emacs are you using? smtpmail-starttls-credentials was removed 8 years ago. The reason you're getting prompted is because the default value of smtpmail-smtp-service is 25, which means the auth-source lookup is being done with that value. Set it to 587, and have 587 in your .authinfo, and it should all work. – rpluim Sep 16 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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