Features include:
Another bonus is that Msmtp seems to be very portable, for example on some alternative architectures (x86_64 for one).
Requirements
Optionally you need >=gnutls-1.0.0, >=openssl-0.9.6, and libgsasl / gsasl.
Installation
This is simple. Your distribution most likely provides a package, or you can just get the source from their Sourceforge project page.
The main options to ./configure to worry about are:
For Gentoo package you can simple use the USE flags gnutls, ssl, and sasl.
Setup
First, you need to setup an ~/.msmtprc. This config file has a simple syntax. Here is a simple example:
account default host mail.yourisp.com user johnsmith password spork tls
IMPORTANT! Msmtp will refuse to send your mail if you have tls in your ~/.msmtprc and your SMTP server has a TLS certificate that you do not trust. To get around this, either trust the certificate, or you can add tls_nocertcheck to your ~/.msmtprc.
The auth [<method>] can be added. It is not recommended to define an auth type yourself, but instead to just set auth with no arguments and let Msmtp choose the best one. However, if you must, see man msmtp for available arguments.
Msmtp supports multiple accounts. Set account <name> in your ~/.msmtprc and then you can use msmtp -a <name>.
In your ~/.muttrc you need to use:
set sendmail="/path/to/msmtp"
Use macros or send2-hooks to select a profile if you use them. Like:
send2-hook . 'set sendmail="/path/to/msmtp"' send2-hook '~f gmx' 'set sendmail="/path/to/msmtp -a gmx"' macro index ,g '<enter-command>set sendmail="/path/to/msmtp -a gmx"<enter>' 'choose gmx smtp profile'
See MuttFaq/Header how to configure From: in a nice way.
Here is a script for parsing the ~/.msmtprc file in order to write macros allowing to easely select the current profile from the compose-context by pressing the <tab> key until the right account has been reached. The macros are quite robust, well described in the help page. The profile can also be chosen from any context by pressing Ctrl-x 0, Ctrl-x 1, etc.
#!/bin/sh
awk -F "[[:space:]]" '
BEGIN { n = 0; }
/^[[:space:]]*account[[:space:]]+[[:print:]]/ {
gsub("[[:space:]]*account[[:space:]]+","");
t[n] = $0; n++;
}
END {
l = " \"Internal macro from the MSMTP module\""
c = " the current MSMTP account"
print "macro generic \\Cx_ \"<enter-command>set sendmail\"" l
print "macro generic \\Cx| \"\\Cx_ = \\\"/usr/local/bin/msmtp\"" l
print "macro generic \\Cx& \"<enter-command>macro compose \\\\t"\
" \\\"\\\\Cx\"" l
print "macro compose <tab> \"\\Cx1\" \"Change" c "\""
print "macro compose = \"\\Cx_\\n\" \"Show" c "\""
for(i=0;i<n;i++) {
a = t[i];
if(a=="default") a = "\\\"\\n";
else a = " -a " a "\\\"\\n";
print "macro generic \\Cx" i " \"\\Cx|" a "\\Cx&" (i+1)%n\
"\\\" \\\"Change" c "\\\"\\n\\Cx_\\n\""\
" \"Switch to account n° " i " for MSMTP\""
}
}
' ~/.msmtprc
(the correct path for the executable may have to be fixed at line 12; these macros work for at least 2 and at most 10 different accounts).