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 "[email protected]"
 smtpmail-default-smtp-server "smtp.office365.com"
 smtpmail-smtp-server         "smtp.office365.com"
 smtp-mail-service 587
 smtpmail-local-domain        "[email protected]")

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

  • perhaps : message-send-mail-function 'smtpmail-send-it ? Nov 27, 2018 at 17:24
  • Isn't that the second line of my code? Nov 27, 2018 at 19:04
  • it is... you are right . what about a smtpmail-stream-type value 'starttls or other? Nov 27, 2018 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 "[email protected]" "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? Nov 30, 2018 at 11:52
  • That should be in your .offlineimaprc file. Nov 30, 2018 at 12:30

2 Answers 2


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 [email protected] port 587 password XYZ

You can use port 587 (TLS, secure), or port 25 (no TLS, non-secure). If you use 587, you need to also set the auth-source lookup to that value:

(setq smtpmail-smtp-service 587)

For password protection look at .netrc , or GPG.

Update from OP: in a previous version, I used port 25 (SMTP without TLS) in ~/.authinfo, else I was prompted with SMTP user name for smtp.office365.com (default email):. Thanks to @rpluim for the setting of smtpmail-smtp-service in a comment to @Cenderme's answer.

  • 1
    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, 2018 at 8:41
  • I tried with 465 both for smtpmail-smtp-service and on .authinfo and it fails, despite the company (which is now different from Microsoft) having a page with "Server: mail.secure.aluminati.net (Port: 587, if that fails try 465)". Is there a different setting for 465, and why is 465 better? Nov 2, 2019 at 21:01

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

 user-mail-address "[email protected]"
 message-send-mail-function   'smtpmail-send-it
 smtpmail-smtp-service 587
 smtpmail-smtp-server         "smtp.office365.com"
 smtpmail-stream-type 'starttls
 ;;smtpmail-auth-credentials '(expand-file-name "~/.authinfo.gpg") Please read the update and comments.

I use spacemacs, so you might want to change these lines. Rearrange your ~/.authinfo file as in

machine smtp.office365.com login [email protected] 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.

Update from OP: @rpluim suggested that this code is redundant: (setq smtpmail-starttls-credentials '(("smtp.office365.com" 587 nil nil))) because smtpmail-starttls-credentials was removed 8 years ago. @rpluim also suggested setting smtpmail-smtp-service to 587 to coincide with the port in ~/.authinfo. Both changes work in sending mail.

  • Good answer that includes GPG and password file encryption. Sep 14, 2019 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? Sep 14, 2019 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 protected]:. 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? Sep 15, 2019 at 7:48
  • 1
    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, 2019 at 9:42
  • I was using Emacs 26.3. I confirm that your changes work and updated the answer. Thanks for the help on 587 versus 25, I now have a more secure SMTP setup. Nov 2, 2019 at 20:36

Your Answer

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

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