MSMTP(1)

NAME
msmtp - An SMTP client

SYNOPSIS

Sendmail mode (default):
    msmtp [option...] [--] recipient...
    msmtp [option...] -t [--] [recipient...]

Server information mode:
    msmtp [option...] --serverinfo

Remote Message Queue Starting mode:
    msmtp [option...] --rmqs=host|@domain|#queue

DESCRIPTION
In the default sendmail mode, msmtp reads a mail from standard input and sends it to an SMTP server for delivery.
In server information mode, msmtp prints information about an SMTP server.
In Remote Message Queue Starting mode, msmtp sends a Remote Message Queue Starting request for a host, domain, or queue to an SMTP server.

EXIT STATUS
The standard sendmail exit status codes are used, as defined in sysexits.h.

OPTIONS
Options override configuration file settings.
They are compatible with sendmail where appropriate.

General options

    --version
        Print version information. This includes information about the library used for TLS/SSL support (if any), the library used for authentication, the authentication mechanisms supported by this library, and the default locations of the system and user configuration files.

    --help
        Print help.

    -P, --pretend
        Print the configuration settings that would be used, but do not take further action. An asterisk ('*') will be printed instead of your password.

    -d, --debug
        Print lots of debugging information, including the whole conversation with the SMTP server. Be careful with this option: the (potentially dangerous) output will not be sanitized, and your password may get printed in an easily decodable format!

Changing the mode of operation

    -S, --serverinfo
        Print information about the SMTP server and exit. This includes information about supported features (mail size limit, authentication, TLS, DSN, ...) and about the TLS certificate (if TLS is active).

    --rmqs=(host|@domain|#queue)
        Send a Remote Message Queue Starting request for the given host, domain, or queue to the SMTP server and exit.

Configuration options

    -C, --file=filename
        Use the given file instead of ~/.msmtprc as the user configuration file.

    -a, --account=account_name
        Use the given account instead of the account named "default". The settings of this account may be changed with command line options. This option cannot be used together with the --host option.

    --host=hostname
        Use this SMTP server with settings from the command line; do not use any configuration file data. This option cannot be used together with the --account option.

    --port=number
        Set the port number to connect to. See the port command below.

    --timeout=(off|seconds)
        Set a network timeout. See the timeout command below. For compatibility with older versions, --connect-timeout is accepted as an alias for this option.

    --protocol=(smtp|lmtp)
        Set the protocol to use. See the protocol command below.

    --auth[=(on|off|method)]
        Enable or disable authentication. You can optionally choose the method. See the auth command below.

    --user=[username]
        Set or unset the user name for authentication. See the user command below.

    --tls[=(on|off)]
        Enable or disable TLS encryption. See the tls command below.

    --tls-starttls[=(on|off)]
        Enable or disable STARTTLS for TLS encryption. See the tls_starttls command below.

    --tls-trust-file=[file]
        Set or unset a trust file for TLS encryption. See the tls_trust_file command below.

    --tls-key-file=[file]
        Set or unset a key file for TLS encryption. See the tls_key_file command below.

    --tls-cert-file=[file]
        Set or unset a cert file for TLS encryption. See the tls_cert_file command below.

    --tls-certcheck[=(on|off)]
        Enable or disable server certificate checks for TLS encryption. See the tls_certcheck command below.

    --tls-force-sslv3[=(on|off)]
        Force TLS/SSL version SSLv3. See the tls_force_sslv3 command below.

    --domain=[string]
        Set the argument of the SMTP EHLO (or LMTP LHLO) command. See the domain command below.

Options specific to sendmail mode

    --auto-from[=(on|off)]
        Enable or disable automatic envelope-from addresses. The default is off. See the auto_from command below.

    -f, --from=address
        Set the envelope-from address. It is only used when auto_from is off.
        If no account was chosen yet (with --account or --host), this option will choose the first account that has the given envelope-from address (set with the from command). If no such account is found, "default" is used.

    --maildomain=[domain]
        Set the domain part for generated envelope-from addresses. It is only used when auto_from is on. See the maildomain command below.

    -N, --dsn-notify=(off|cond)
        Set or unset DSN notification conditions. See the dsn_notify command below.

    -R, --dsn-return=(off|ret)
        Set or unset the DSN notification amount. See the dsn_return command below. Note that hdrs is accepted as an alias for headers to be compatible with sendmail.

    --keepbcc[=(on|off)]
        Enable or disable the preservation of the Bcc header. See the keepbcc command below.

    -X, --logfile=[file]
        Set or unset the log file. See the logfile command below.

    --syslog[=(on|off|facility)]
        Enable or disable syslog logging. See the syslog command below.

    -t, --read-recipients
        Read recipient addresses from the To, Cc, and Bcc headers of the mail in addition to the recipients given on the command line.

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

The following options are accepted but ignored for sendmail compatibility:
-Btype, -bm, -Fname, -G, -hN, -i, -L tag, -m, -n, -O option=value, -ox value, -v

USAGE
Normally, a system wide configuration file and/or a user configuration file contain information about which SMTP server to use (and how to use it), but almost all settings can also be configured on the command line.

Information about SMTP servers is organized in accounts. Each account describes one SMTP server: host name, authentication settings, TLS settings, and so on. Each configuration file can define multiple accounts.

In sendmail mode, an envelope-from address is necessary to send mail. This is the mail address that will be presented to the SMTP server as the originator of the mail. Envelope-from addresses can be generated automatically (when auto_from is enabled) or set explicitly with the from command or --from option. When auto_from is enabled, an envelope-from address of the form user@domain will be generated. The local part will be set to $USER or, if that fails, to $LOGNAME or, if that fails, to the login name of the current user. The domain part can be set with the maildomain command. If the maildomain is empty, the envelope-from address will only consist of the user name and not have a domain part.

The user can choose which account to use in one of three ways:

--account=id
    Use the given account. Command line settings override configuration file settings.

--host=hostname
    Use only the settings from the command line; do not use any configuration file data.

--from=address
    Choose the first account from the system or user configuration file that has a matching envelope-from address as specified by a from command. This works only when neither --account nor --host is used.

If none of the above options is used (or if --from is used but no account has a matching from command), then the account "default" is used.

Skip to the EXAMPLES section for a quick start.

CONFIGURATION FILES
If it exists and is readable, a system wide configuration file SYSCONFDIR/msmtprc will be loaded, where SYSCONFDIR depends on your platform. Use --version to find out which directory is used.
If it exists and is readable, a user configuration file will be loaded (~/.msmtprc by default). Accounts defined in the user configuration file override accounts from the system configuration file. The user configuration file must have no more permissions than user read/write. Configuration data from either file can be changed by command line options.

A configuration file is a simple text file. Empty lines and comment lines (whose first non-blank character is '#') are ignored.
Every other line must contain a command and may contain an argument to that command.
The argument may be enclosed in double quotes ("), for example if its first or last character is a blank.
If the first character of a filename is the tilde (~), this tilde will be replaced by $HOME. If a command accepts the argument on, it also accepts an empty argument and treats that as if it was on.
Commands form groups. Each group begins with the account command and defines the settings for one SMTP server.

Skip to the EXAMPLES section for a quick start.

Commands are as follows:

defaults
    Set defaults. The following configuration commands will set default values for all following account definitions in the current configuration file.

account name [:account[,...]]
    Start a new account definition with the given name. The current default values are filled in.
    If a colon and a list of previously defined accounts is given after the account name, the new account, with the filled in default values, will inherit all settings from the accounts in the list.

host hostname
    The SMTP server to send the mail to. The argument may be a host name or a network address. Every account definition must contain this command.

port number
    The port that the SMTP server listens on. The default port will be acquired from your operating system's service database: for SMTP, the service is "smtp" (default port 25), unless TLS without STARTTLS is used, in which case it is "ssmtp" (465). For LMTP, it is "lmtp".

timeout (off|seconds)
    Set or unset a network timeout, in seconds. The argument off means that no timeout will be set, which means that the operating system default will be used.
    For compatibility with older versions, connect_timeout is accepted as an alias for this command.

protocol (smtp|lmtp)
    Set the protocol to use. Currently only SMTP and LMTP are supported. SMTP is the default. See the port command above for default ports.

auto_from [(on|off)]
    Enable or disable automatic envelope-from addresses. The default is off. When enabled, an envelope-from address of the form user@domain will be generated. The local part will be set to $USER or, if that fails, to $LOGNAME or, if that fails, to the login name of the current user. The domain part can be set with the maildomain command. If the maildomain is empty, the envelope-from address will only consist of the user name and not have a domain part. When auto_from is disabled, the envelope-from address must be set explicitly.

from envelope_from
    Set the envelope-from address. This address will only be used when auto_from is off.

maildomain [domain]
    Set a domain part for the generation of an envelope-from address. This is only used when auto_from is on. The domain may be empty.

auth [(on|off|method)]
    This command enables or disables SMTP authentication. You should not need to set the method yourself; with the argument on, msmtp will choose the best one available for you (see below).
    You probably need to set a username (with user) and password (with password). If no password is set but one is needed during authentication, msmtp will try to find it in ~/.netrc, and if that fails, msmtp will prompt you for it.
    Available methods are plain, cram-md5, digest-md5, gssapi, external, login, and ntlm. Note that one or more of these methods may be unavailable due to lack of support in the underlying authentication library. Use the --version option to find out which methods are supported.
    The plain and login methods send your authentication data in cleartext over the net and should therefore only be used together with the tls command.
    If you don't choose the method yourself, msmtp chooses the best secure method that the SMTP server supports. Secure means that your authentication data will not be sent in cleartext over the net. For TLS encrypted connections, every authentication method is secure in this sense. If TLS is not active, only gssapi, digest-md5, cram-md5 and ntlm are secure in this sense.
    The external is special: the actual authentication happens outside of the SMTP protocol, typically by sending a TLS client certificate (see the tls_cert_file command). The external method merely confirms that this authentication succeeded for the given user (or, if no user name is given, confirms that authentication succeeded). This authentication method is not chosen automatically; you have to request it manually.

user [username]
    Set your user name for SMTP authentication. An empty argument unsets the user name. Authentication must be activated with the auth command.

password [secret]
    Set your password for SMTP authentication. An empty argument unsets the password. Authentication must be activated with the auth command. If no password is set but one is needed during authentication, msmtp will try to find it in ~/.netrc, and if that fails, msmtp will prompt you for it.

ntlmdomain [domain]
    Set a domain for the ntlm authentication method. The default is to use no domain (equivalent to an empty argument), but some servers seem to require one, even if it is an arbitrary string.

tls [(on|off)]
    This command enables or disables TLS/SSL encrypted connections to the SMTP server. Not every server supports TLS. With TLS, the connection with the SMTP server will be protected against eavesdroppers. A sanity check will be performed on the server certificate (unless the tls_certcheck command is used to turn this off, see below). To make full use of the TLS/SSL capabilities, it is recommended to use the tls_trust_file command (see below).

tls_starttls [(on|off)]
    By default, TLS encryption is activated using the STARTTLS SMTP command. By disabling this, TLS encryption is immediately started instead (this is known as SMTP tunneled through TLS/SSL). The default port is set to 465 for this mode of operation.
    For compatibility with older versions, tls_nostarttls is accepted as an alias for tls_starttls off.

tls_trust_file [file]
    This command activates strict server certificate verification. The file must contain one or more certificates of trusted Certification Authorities (CAs) in PEM format. An empty argument disables this feature. With a trust file, msmtp can verify the authenticity of the server it connects to.

tls_key_file [file]
    This command (together with the tls_cert_file command) enables msmtp to send a client certificate to the SMTP server if requested. The file must contain the private key of a certificate in PEM format. An empty argument disables this feature.

tls_cert_file [file]
    This command (together with the tls_key_file command) enables msmtp to send a client certificate to the SMTP server if requested. The file must contain a certificate in PEM format. An empty argument disables this feature.

tls_certcheck [(on|off)]
    By default, sanity checks are performed on server certificate(s) when TLS is used. If the certificate(s) don't pass the checks, the TLS connection is aborted. This command can turn the checks off.
    For compatibility with older versions, tls_nocertcheck is accepted as an alias for tls_certcheck off.

tls_force_sslv3 [(on|off)]
    Force TLS/SSL version SSLv3. This might be needed to use SSL with some old and broken servers. Do not use this unless you have to.

dsn_notify (off|condition)
    This command sets the condition(s) under which the mail system should send DSN (Delivery Status Notification) messages. The argument off disables explicit DSN requests, which means the mail decides when to send DSN messages. This is the default. The condition must be never, to never request notification, or a comma separated list (no spaces!) of one or more of the following: failure, to request notification on transmission failure, delay, to be notified of message delays, success, to be notified of successful transmission. The SMTP server must support the DSN extension.

dsn_return (off|amount)
    This command controls how much of a mail should be returned in DSN (Delivery Status Notification) messages. The argument off disables explicit DSN requests, which means the mail system decides how much of a mail it returns in DSN messages. This is the default. The amount must be headers, to just return the message headers, or full, to return the full mail. The SMTP server must support the DSN extension.

domain argument
    Use this command to set the argument of the SMTP EHLO (or LMTP LHLO) command. The default is localhost (stupid, but working). Possible choices are the domain part of your mail address (provider.example for joe@provider.example) or the fully qualified domain name of your host (if available).

keepbcc [(on|off)]
    This command controls whether to remove or keep the Bcc header when sending a mail. The default is to remove it.

logfile [file]
    An empty argument disables logging (this is the default).
    When logging is enabled by choosing a log file, msmtp will append one line to the log file for each mail it tries to send via the account that this log file was chosen for.
    The line will include the following information: date and time, host name of the SMTP server, whether TLS was used, whether authentication was used, authentication user name (only if authentication is used), envelope-from address, recipient addresses, size of the mail as transferred to the server (only if the delivery succeeded), SMTP status code and SMTP error message (only in case of failure and only if available), error message (only in case of failure and only if available), exit code (from sysexits.h; EX_OK indicates success).
    If the filename is a dash (-), msmtp prints the log line to the standard output.

syslog [(on|off|facility)]
    Enable or disable syslog logging. The facility can be one of LOG_USER, LOG_MAIL, LOG_LOCAL0, ..., LOG_LOCAL7. The default is LOG_USER.
    Each time msmtp tries to send a mail via the account that contains this syslog command, it will log one entry to the syslog service with the chosen facility.
    The line will include the following information: host name of the SMTP server, whether TLS was used, whether authentication was used, envelope-from address, recipient addresses, size of the mail as transferred to the server (only if the delivery succeeded), SMTP status code and SMTP error message (only in case of failure and only if available), error message (only in case of failure and only if available), exit code (from sysexits.h; EX_OK indicates success).

EXAMPLES
Configuration file

# Set default values for all following accounts.
defaults
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
# A freemail service
account freemail
host smtp.freemail.example
from joe_smith@freemail.example
auth on
user joe.smith
password secret
# A second mail address at the same freemail service
account freemail2 : freemail
from joey@freemail.example
# The SMTP server of the provider.
account provider
host mail.provider.example
from smithjoe@provider.example
auth on
user 123456789
password my_password
# Set a default account
account default : provider

Using msmtp with Mutt

Create a configuration file for msmtp and add the following lines to your Mutt configuration file:
set sendmail="/path/to/msmtp"
set use_from=yes
set realname="Your Name"
set from=you@example.com
set envelope_from=yes
The envelope_from=yes option lets Mutt use the -f option of msmtp. Therefore msmtp chooses the first account that matches the from address you@example.com.
Alternatively, you can use the -a option:
set sendmail="/path/to/msmtp -a my-account"
Or set everything from the command line:
set sendmail="/path/to/msmtp --host=mailhub -f me@example.com --tls"

If you have multiple mail accounts in your msmtp configuration file and let Mutt use the -f option to choose the right one, you can easily switch accounts in Mutt with the following Mutt configuration lines:
macro generic "<esc>1" ":set from=you@example.com"
macro generic "<esc>2" ":set from=you@your-employer.example"
macro generic "<esc>3" ":set from=you@some-other-provider.example"

Using msmtp with mail

Define a default account, and put the following in your ~/.mailrc:
set sendmail="/path/to/msmtp"

FILES / ENVIRONMENT

SYSCONFDIR/msmtprc
    System configuration file. Use --version to find out what SYSCONFDIR is on your platform.

~/.msmtprc
    User configuration file.

~/.netrc
    The .netrc file contains login information. If a password is not found in the configuration file, msmtp will search it in .netrc before prompting the user for it. The syntax of .netrc is described in netrc(5) or ftp(1).

$USER, $LOGNAME
    These variables override the user's login name when constructing an envelope-from address. $LOGNAME is only used if $USER is unset.

$TMPDIR
    Directory to create temporary files in. If this is unset, a system specific default directory is used.
    A temporary file is only created when the -t/--read-recipients option is used. The file is then used to buffer the headers of the mail (but not the body, so the file won't get very large).

AUTHORS
msmtp was written by Martin Lambers <marlam@marlam.de>.
Other authors are listed in the AUTHORS file in the source distribution.

SEE ALSO
mutt(1), mail(1), sendmail(8), netrc(5) or ftp(1)