]> git.cworth.org Git - notmuch-wiki/blobdiff - emacstips.mdwn
Document how to use msmtp with multiple accounts
[notmuch-wiki] / emacstips.mdwn
index a528ebffb88052c7ef43205d2ccfa843597a0e33..96c8b1046423f1b247d761f2e0cbc8e3d56fed8c 100644 (file)
@@ -49,9 +49,9 @@ If you want to use mail address autocompletion, check out [bbdb](http://bbdb.sou
 Type your message and send it off with ctrl-c ctrl-c. By default message mode will use your /usr/sbin/sendmail command to send a mail, so make sure that works.
 One annoying standard configuration of message mode is that it will hide the sent mail in your emacs frame stack, but it will not close it. If you type several mails in an emacs session they will accumulate and make switching between buffers more annoying. You can avoid that behavior by adding `(setq message-kill-buffer-on-exit t)` in your .emacs file which will really close the mail window after sending it.
 
-Currently, there is a slight problem with copying the sent mail into your "outbox". While conventional MUAs will automatically copy your sent mail to a "Sent" folder, notmuch will never touch your mail store and your sent mails will not be searchable by default. When replying with 'r' notmuch will insert a BCC header to yourself, but when sending a mail with 'm' or 'ctrl-x m', it will not (and can not as ctrl-x m does not involve notmuch at all). Please see the specific advice on "[how to do FCC/BCC](fcc)" for more details on how to set up notmuch to obey your preferences.
+Currently, there is a slight problem with copying the sent mail into your "outbox". While conventional MUAs will automatically copy your sent mail to a "Sent" folder, notmuch will never touch your mail store and your sent mails will not be searchable by default. When replying with 'r' notmuch will insert a BCC header to yourself, but when sending a mail with 'm' or 'ctrl-x m', it will not (and can not as ctrl-x m does not involve notmuch at all). Please see the specific advice on "[how to do FCC/BCC](#fcc)" for more details on how to set up notmuch to obey your preferences.
 
-===3rd party application
+###3rd party application
 
 As its name implies, notmuch isn't really doing that much (which is part of its appeal to many of us). However, it enables a whole ecosystem of surrounding scripts to work in conjunction with notmuch
 
@@ -124,6 +124,33 @@ As its name implies, notmuch isn't really doing that much (which is part of its
   already running, it seems to shut down when the script exits. I
   don't know why."
 
+* msmtp, message mode and multiple accounts
+
+  As an alternative to running a mail server such as sendmail or
+  postfix just to send email, it is possible to use
+  [msmtp](http://msmtp.sourceforge.net/).  This small application will
+  look like /usr/bin/sendmail to a MUA such as emacs message mode, but
+  will just forward the email to an external SMTP server.  It's fairly
+  easy to set up and it support several account for using different
+  SMTP servers.  A typical scenario is that you want to use the
+  company SMTP server for email coming from your company email
+  address, and your personal server for personal email.  If msmtp is
+  passed the envelope address on the command line (the , it will
+  automatically pick the matching account.  The only trick here seems
+  to be getting emacs to actually pass the envelope from.  There are a
+  number of overlapping configuration variables that control this, and
+  it's a little confusion, but setting these three works for me:
+
+   - mail-specify-envelope-from: t
+
+   - message-sendmail-envelope-from: header
+
+   - mail-envelope-from: header
+
+  With that in place, you need a .msmtprc with the accounts configured
+  for the domains you want to send out using specific SMTP servers and
+  the rest will go to the default account.
+
 * <span id="sync_maildir_flags">how to sync notmuch tags and maildir flags]</span>
 
   __[TODO: This is a wiki. write me!]__