0

I use Emacs and mu4e to send mail. I have a mail server with Amazon WorkMail and I set up the information at ~/.authinfo.gpg. Two domains are in the same region and have the same SMTP server with different usernames. When I send email from the second, it is sent with the credentials from the first which appears at the top of the list.

My code is:

(defvar my-mu4e-account-alist
  '(
    ("Account1"
     (mu4e-sent-folder "/Account1/Sent Items")
     (mu4e-drafts-folder "/Account1/Drafts")
     (mu4e-trash-folder "/Account1/Deleted Items")
     (user-mail-address "[email protected]")
     (smtpmail-smtp-user "[email protected]")
     (smtpmail-stream-type ssl)
     (smtpmail-smtp-service 465)
     )
    ("Account2"
     (mu4e-sent-folder "/Account2/Sent Items")
     (mu4e-drafts-folder "/Account2/Drafts")
     (mu4e-trash-folder "/Account2/Deleted Items")
     (user-mail-address "[email protected]")
     (smtpmail-smtp-server "smtp.mail.eu-west-1.awsapps.com")
     (smtpmail-stream-type ssl)
     (smtpmail-smtp-service 465)
     )
    ))

How can I force each account to use its own account on the server?

miguelmorin
  • 1,907
  • 12
  • 33

1 Answers1

0

I read the manual again:

If the variable smtpmail-smtp-user is set to a non-nil value, then only entries for that user are considered. For more information on the ~/.authinfo file, see auth-source.

So I used this and it worked:

(defvar my-mu4e-account-alist
  '(
    ("Account1"
     (mu4e-sent-folder "/Account1/Sent Items")
     (mu4e-drafts-folder "/Account1/Drafts")
     (mu4e-trash-folder "/Account1/Deleted Items")
     (user-mail-address "[email protected]")
     (smtpmail-smtp-user "[email protected]")
     (smtpmail-smtp-server "smtp.mail.eu-west-1.awsapps.com")
     (smtpmail-stream-type ssl)
     (smtpmail-smtp-service 465)
     )
    ("Account2"
     (mu4e-sent-folder "/Account2/Sent Items")
     (mu4e-drafts-folder "/Account2/Drafts")
     (mu4e-trash-folder "/Account2/Deleted Items")
     (user-mail-address "[email protected]")
     (smtpmail-smtp-user "[email protected]")
     (smtpmail-smtp-server "smtp.mail.eu-west-1.awsapps.com")
     (smtpmail-stream-type ssl)
     (smtpmail-smtp-service 465)
     )
    ))
miguelmorin
  • 1,907
  • 12
  • 33