msmtp

NAME
DESCRIPTION
SYNOPSIS
OPTIONS
THE CONFIGURATION FILE
EXAMPLE CONFIGURATION FILE
USING MSMTP WITH MUTT
NOTES
AUTHOR

NAME

msmtp − An SMTP plugin for MUAs

DESCRIPTION

msmtp is a an SMTP "plugin" for Mutt and probably other MUAs (mail user agents). It forwards mails to an SMTP server (for example at a free mail provider) which does the delivery.

To use this program, create a configuration file with your mail account(s) and tell your MUA to call msmtp instead of /usr/sbin/sendmail.

SYNOPSIS

msmtp [OPTIONS] [--] rcpt1 [[rcpt2] ...]

There must be at least one recipient mail address on the command line.

OPTIONS

-v, --version

Print version and exit.

-h, --help

Print help and exit.

-f, --file=conffile

Use the given file instead of $HOME/.msmtprc as configuration file.

-a, --account=account_name

Use the given account instead of the account named "default".

--

This marks the end of options. All following arguments will be treated as recipient addresses, even if they start with a ’-’.

THE CONFIGURATION FILE

The configuration file ($HOME/.msmtprc by default) is a simple text file. Empty lines and lines whose first non-blank character is ’#’ are ignored. All other lines must contain a command word and may contain an argument word (dependent on the command) divided by at least one blank character. All other blanks are ignored, so neither commands nor arguments may contain blanks. See below for examples.

Commands are:

account <name>

Start a new account definition with the given name. The first account definition in the file does not need to start with this command; it will be named "default" if it does not.

host <smtpserver>

The SMTP server to send the mail to. This host is supposed to send the mail to the recipients. The argument may be a host name, an IPv4 address in dot notation, or an IPv6 address in colon notation. Every account definition must contain this command.

port <portnumber>

The port that the SMTP server listens on. The default is 25 and should always work.

from <envelope_from>

Your mail address that the SMTP server knows of (the envelope-from address). Every account definition must contain this command.

auth [<method>]

This command enables SMTP authentication. You do not need to specify a method, msmtp can choose one for you (see below). Available methods are: plain (the AUTH PLAIN method), login (the AUTH LOGIN method), and cram_md5 (the AUTH CRAM-MD5 method).
The plain and login methods send your authentication data unencrypted over the net. It may be possible for an attacker to steal your username and password unless you use the tls command to encrypt all communication with the SMTP server. The cram_md5 method uses a fairly secure method to send your authentication data.
If you don’t choose the method yourself, msmtp chooses a secure method for you: plain for TLS encrypted connections and cram_md5 for unencrypted connections. msmtp will never use an insecure method if you don’t explicitly tell it to do so!
If you activate SMTP authentication, you must give your user name and password with the appropriate commands, too.

user <login>

Set your user name for SMTP authentication.
If you did not use the auth command, this command will automatically activate SMTP authentication with automatic selection of a secure method (just as if you used auth without an argument).
Be sure that your configuration file is only readable by yourself if you store authentication data in it!

password <secret>

Set your password for SMTP authentication.
If you did not use the auth command, this command will automatically activate SMTP authentication with automatic selection of a secure method (just as if you used auth without an argument).
Be sure that your configuration file is only readable by yourself if you store authentication data in it!

tls [<method>]

This command enables TLS/SSL encrypted connections to the SMTP server. Mail delivery will fail if the SMTP server does not support this feature.
You do not need to choose the method yourself, msmtp will automatically choose the best method available with the SMTP server.
If the SMTP server supports TLS/SSL encrypted connections, it is generally a good idea to use this command. If you do not know whether the SMTP server supports TLS/SSL, simply try this command, you will get an appropriate message if it does not.
You can manually choose one of the following methods (if the SMTP server does not accept the method you choose, the mail delivery will fail): tls1 means TLSv1 (this is the newest and best method), ssl3 means SSLv3 and ssl2 means SSLv2.

nostarttls

This command tells msmtp to assume that the remote SMTP server operates exclusively under TLS/SSL and the STARTTLS command is not needed (for example a stunnel wrapped version of regular unencrypted SMTP server). This command is only useful in conjunction with the tls command.

keep-bcc

This command tells msmtp to keep the Bcc header in the mail. The default is to remove the Bcc before sending the mail to the SMTP server. Use this command only if you know exactly what you are doing.

EXAMPLE CONFIGURATION FILE

# Use the mail transport agent running on your computer.
account default
host localhost
from me@mybox.example

# Use an external SMTP server
account provider1
host smtp.provider1.example
from me@provider1.example

# Use an external SMTP server with authentication.
# (msmtp will choose CRAM-MD5 authentication, because we don’t use TLS
# encryption.)
account provider2
host smtp.provider2.example
from m_e@provider2.example
user m_e
password s!e"c%r*e/t

# Use an external SMTP server with authentication and TLS encryption.
# (msmtp will choose PLAIN authentication, because TLS encryption is
# active.)
account provider3
host mail.provider3.example
from me_prov3@provider3.example
user me_prov3_111238476
password stupid_password
tls

# Use an external SMTP server with insecure authentication.
# (manually choose LOGIN authentication though TLS encryption is not
# active.)
account provider4
host herb.provider4.example
from xyz@provider4.example
auth login
user xyz@provider4.example
password this_will_be_easy_to_read

# Use an external SMTP server.
# Use CRAM-MD5 authentication even with active TLS encryption.
# Insist on TLSv1 for TLS encryption.
# Assume the server runs in TLS-only mode and listens on port 123.
account unusual_provider
host weird.provider.example
port 123
from name@provider.example
auth cram_md5
user name-1378
password 10340712937
tls tls1
nostarttls

USING MSMTP WITH MUTT

If you want to use msmtp with Mutt, create a configuration file for msmtp and add the following line to your Mutt configuration file:
set sendmail="/path/to/msmtp"

Do not add "--" to this line, because Mutt will add "--" itself.

You might want to add
set use_from=no
my_hdr From: "Your Name" <yourmail@yourprovider.com>

to Mutt’s configuration file (see the Mutt manual).

Note that msmtp does not understand sendmail options, so some Mutt configuration options will not work. For example, avoid "set envelope_from" (which adds the -f option to msmtp’s commandline). The envelope from address is set in your msmtp configuration file anyway.

If you have multiple mail accounts in your msmtp configuration file (called "default", "work", "extra" for example), you can easily switch between them in Mutt:

Add the following lines to your Mutt configuration file:
set sendmail="/path/to/msmtp"
macro generic "<esc>1" ":set sendmail=\"/path/to/msmtp\""
macro generic "<esc>2" ":set sendmail=\"/path/to/msmtp -a work\""
macro generic "<esc>2" ":set sendmail=\"/path/to/msmtp -a extra\""

You can now switch between the accounts with <esc>1 (use "default" account), <esc>2 (use "work" account), <esc>3 (use "extra" account).

NOTES

msmtp is not intended to replace /usr/sbin/sendmail. It does not understand sendmail options and can’t do local deliveries.

AUTHOR

msmtp was written by Martin Lambers <marlam@users.sourceforge.net>

The base64enc(), base64dec(), and cram_md5() functions were adapted from GNU Anubis, Copyright (C) 2001, 2002 The Anubis Team.