Krusty writes:

> Does anyone have an example .emacs (or other config file) using mu4e
> to send mail from multiple gmail accounts? I've got three different
> sets of credentials & if I save any one of them to .authinfo, the
> other two break when I try to send as the other userid.
>
> My guess is that this can be done easiest with msmtp, but I haven't
> found a formula that works yet.

The following setup works for me.

======================= my .msmtprc file ===============================

# Accounts will inherit settings from this section
# Since both my accounts are Gmail, lots here
defaults
host            smtp.gmail.com
port            587
auth            on
tls             on
tls_trust_file  /etc/ssl/certs/ca-certificates.crt

# A first gmail address
account         first
from            [email protected]
user            [email protected]

# A second gmail address
account         second    
from            [email protected]
user            [email protected]

# Set a default account
account default : first

=========================================================================


Then my .emacs has the following snippet, which I believe came from the
EmacsWiki, though I can't recall exactly where.

========================================================================
;; Choose account label to feed msmtp -a option based on From header
;; in Message buffer; This function must be added to
;; message-send-mail-hook for on-the-fly change of From address before
;; sending message since message-send-mail-hook is processed right
;; before sending message.
(defun choose-msmtp-account ()
  (if (message-mail-p)
      (save-excursion
        (let*
            ((from (save-restriction
                     (message-narrow-to-headers)
                     (message-fetch-field "from")))
             (account
              (cond
               ((string-match "[email protected]" from) "first")
               ((string-match "[email protected]" from) "second"))))
          (setq message-sendmail-extra-arguments (list '"-a" account))))))

(setq message-sendmail-envelope-from 'header)
(add-hook 'message-send-mail-hook 'choose-msmtp-account)

========================================================================

Hope that helps.

Best,
Josiah

-- 
You received this message because you are subscribed to the Google Groups 
"mu-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to