\input texinfo	 @c -*-texinfo-*-
@setfilename msmtp.info
@documentlanguage en
@documentencoding UTF-8
@include version.texi
@settitle msmtp @value{VERSION}

@c Define new indices: for options (op) and commands (cm)
@defcodeindex op
@defcodeindex cm

@finalout
@copying
This manual was last updated @value{UPDATED} for version
@value{VERSION} of msmtp.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
Martin Lambers@*
Copyright (C) 2011
Scott Shumate

@quotation
Copying and distribution of this file, with or without modification, are
permitted in any medium without royalty provided the copyright notice and this
notice are preserved. These files are offered as-is, without any warranty.
@end quotation
@end copying

@dircategory Individual utilities
@direntry
* msmtp: (msmtp).	An SMTP client.
@end direntry

@titlepage
@title msmtp
@subtitle Version @value{VERSION}, @value{UPDATED}
@author Martin Lambers (@email{marlam@@marlam.de})
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@contents

@ifnottex
@node Top
@top msmtp
@insertcopying
@end ifnottex

@menu
* Introduction::			Basic concepts.
* Configuration files::			Configuration file commands.
* Invocation::				Command line options.
* Transport Layer Security::		How to use TLS/SSL.
* Authentication::			How to use authentication.
* Delivery Status Notifications::	How to use DSN.
* Sendmail mode::			How to send mail.
* Server information mode::		How to obtain information about
					an SMTP server.
* Remote Message Queue Starting mode::	How to send RMQS requests.
* Examples::				Usage examples.
* Minimal SMTP server (msmtpd)::	When and how to use msmtpd.
@end menu


@node Introduction
@chapter Introduction

msmtp is an SMTP client.

In its default mode of operation, it reads a mail from standard input and sends
it to a predefined SMTP server that takes care of proper delivery. Command line
options and exit codes are compatible to sendmail.

The best way to start is probably to have a look at the Examples section.
@xref{Examples}.

In addition to sendmail mode, there are two other modes of operation:
@itemize
@item Server information mode. In this mode, msmtp prints as much information as
it can get about a given SMTP server (supported features, maximum
mail size, @dots{}).
@item Remote Message Queue Starting mode. In this mode, msmtp sends a Remote
Message Queue Starting request for a host, domain, or queue to a given SMTP
server.
@end itemize

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
all settings can also be configured on the command line.

The 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.

Supported features include:
@itemize
@item TLS secured connections (including server certificate verification and
the possibility to send a client certificate)
@item Authentication methods PLAIN, LOGIN, CRAM-MD5 and EXTERNAL
(and GSSAPI, SCRAM-SHA-1, DIGEST-MD5, and NTLM when compiled with GNU SASL
support)
@item Internationalized Domain Names (IDN)
@item DSN (Delivery Status Notification) support
@item PIPELINING support for increased transmission speed
@item RMQS (Remote Message Queue Starting) support (ETRN keyword)
@end itemize


@node Configuration files
@chapter Configuration files

A suggestion for a suitable configuration file can be generated using the
@samp{--configure} option; see @ref{--configure}.

msmtp supports a system wide configuration file and a user configuration file.
Both are optional and need not exist.

If it exists and is readable, a system wide configuration file
@code{SYSCONFDIR/msmtprc} will be loaded. Use @code{--version} to find out
which @code{SYSCONFDIR} your version of msmtp uses.

The default user configuration file is @code{~/.msmtprc} or
@code{$XDG_CONFIG_HOME/msmtp/config}.  Accounts defined in the user
configuration file override accounts from the system configuration file.
Configuration file settings can be changed by command line options.

A configuration file is a simple text file. Empty lines and comment lines
(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 (").

If a file name starts with the tilde (~), this tilde will be
replaced by @code{$HOME}.

If a command accepts the argument @samp{on}, it also accepts an empty argument
and treats that as if it was @samp{on}.

Commands are organized in accounts. Each account starts with the @samp{account}
command and defines the settings for one SMTP account.

@xref{Examples}.

@section General commands

@table @samp
@anchor{defaults}
@item defaults
@cmindex defaults
Set defaults. The following commands will set default values for all following
account definitions in the current configuration file.
@anchor{account}
@item account @var{name} [: @var{account}[,@dots{}]]
@cmindex account
Start a new account definition with the given name. The current default values
are filled in (see @ref{defaults}).@*
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.
@anchor{host}
@item host @var{hostname}
@cmindex host
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.
@anchor{port}
@item port @var{number}
@cmindex port
The port that the SMTP server listens on.
The default is 25 ("smtp"), unless TLS without STARTTLS is used, in which case
it is 465 ("smtps").
@anchor{source_ip}
@item source_ip [@var{IP}]
@cmindex source_ip
Set a source IP address to bind the outgoing connection to. Useful only in
special cases on multi-home systems. An empty argument disables this.
@anchor{proxy_host}
@item proxy_host [@var{IP}|@var{hostname}]
@cmindex proxy_host
Use a SOCKS proxy. All network traffic will go through this proxy host,
including DNS queries, except for a DNS query that might be necessary to
resolve the proxy host name itself (this can be avoided by using an IP address
as proxy host name). An empty argument disables proxy usage.
The supported SOCKS protocol version is 5. If you plan to use this with Tor,
see also @ref{Using msmtp with Tor}.
@anchor{proxy_port}
@item proxy_port [@var{number}]
@cmindex proxy_port
Set the port number for the proxy host. An empty @samp{number} argument resets
this to the default port, which is 1080 ("socks").
@anchor{socket}
@item socket [@var{socketname}]
@cmindex socket
Set the file name of a unix domain socket to connect to. This overrides
both @samp{host}/@samp{port} and @samp{proxy_host}/@samp{proxy_port}.
@anchor{timeout}
@item timeout (off|@var{seconds})
@cmindex timeout
Set or unset a network timeout, in seconds. The argument @samp{off} means that
no timeout will be set, which means that the operating system default will be
used.
@anchor{protocol}
@item protocol (smtp|lmtp)
@cmindex protocol
Set the protocol to use. Currently only SMTP and LMTP are supported. SMTP is
the default. See @ref{port} for default ports.
@anchor{domain}
@item domain @var{argument}
@cmindex domain
This command sets the argument of the SMTP EHLO (or LMTP LHLO) command. The
default is @samp{localhost}, which is stupid but usually works. Try to change
the default if mails get rejected due to anti-SPAM measures. Possible choices
are the domain part of your mail address (@code{provider.example} for
@code{joe@@provider.example}) or the fully qualified domain name of your host
(if available).
@end table

@section Authentication commands

@xref{Authentication}.

@table @samp
@anchor{auth}
@item auth [(on|off|@var{method})]
@cmindex auth
Enable or disable authentication and optionally choose a method to use. The
argument @samp{on} chooses a method automatically.
Accepted methods are @samp{plain}, @samp{scram-sha-1}, @samp{oauthbearer}, @samp{cram-md5},
@samp{gssapi}, @samp{external}, @samp{digest-md5}, @samp{login}, and
@samp{ntlm}.
@xref{Authentication}.@*
@anchor{user}
@item user [@var{username}]
@cmindex user
Set the user name for authentication. An empty argument unsets the user name.
Authentication must be activated with the @samp{auth} command.
@anchor{password}
@item password [@var{secret}]
@cmindex password
Set the password for authentication. An empty argument unsets the password.
Consider using the @samp{passwordeval} command or a key ring instead of this
command, to avoid storing cleartext passwords in the configuration file.
@xref{Authentication}.
@anchor{passwordeval}
@item passwordeval [@var{eval}]
@cmindex passwordeval
Set the password for authentication to the output (stdout) of the command
@var{eval}.
This can be used e.g. to decrypt password files on the fly or to query key
rings, and thus to avoid storing cleartext passwords.
@xref{Authentication}.
@anchor{ntlmdomain}
@item ntlmdomain [@var{ntlmdomain}]
@cmindex ntlmdomain
Set a domain for the @samp{ntlm} authentication method. This is obsolete.
@end table

@section TLS commands

@xref{Transport Layer Security}.

@table @samp
@anchor{tls}
@item tls [(on|off)]
@cmindex tls
Enable or disable TLS (also known as SSL) for secured connections.
@anchor{tls_starttls}
@item tls_starttls [(on|off)]
@cmindex tls_starttls
Choose the TLS variant: start TLS from within the session (@samp{on}, default),
or tunnel the session through TLS (@samp{off}).
@anchor{tls_trust_file}
@item tls_trust_file [@var{file}]
@cmindex tls_trust_file
Activate server certificate verification using a list of trusted Certification
Authorities (CAs). The default is the special value @samp{system}, which selects the
system default. An empty argument disables trust in CAs.
If you select a file, it must be in PEM format, and you should also use
@samp{tls_crl_file}.
@anchor{tls_crl_file}
@item tls_crl_file [@var{file}]
@cmindex tls_crl_file
Set a certificate revocation list (CRL) file for TLS, to check for revoked
certificates. An empty argument disables this.
@anchor{tls_fingerprint}
@item tls_fingerprint [@var{fingerprint}]
@cmindex tls_fingerprint
Set the fingerprint of a single certificate to accept for TLS. This certificate
will be trusted regardless of its contents (this overrides @samp{tls_trust_file}).
The fingerprint should be of type SHA256, but can for backwards compatibility
also be of type SHA1 or MD5 (please avoid this).
The format should be @code{01:23:45:67:@dots{}}.
Use @samp{--serverinfo --tls --tls-certcheck=off --tls-fingerprint=}
to get the server certificate fingerprint.
@anchor{tls_key_file}
@item tls_key_file [@var{file}]
@cmindex tls_key_file
Send a client certificate to the server (use this together with
@samp{tls_cert_file}).
The file must contain the private key of a certificate in PEM format. An empty
argument disables this feature.
@anchor{tls_cert_file}
@item tls_cert_file [@var{file}]
@cmindex tls_cert_file
Send a client certificate to the server (use this together with
@samp{tls_key_file}).
The file must contain a certificate in PEM format. An empty argument disables
this feature.
@anchor{tls_certcheck}
@item tls_certcheck [(on|off)]
@cmindex tls_certcheck
Enable or disable checks of the server certificate. They are enabled by default.@*
Disabling them will override @samp{tls_trust_file} and @samp{tls_fingerprint}.
WARNING: When the checks are disabled, TLS sessions will not be secure!
@anchor{tls_min_dh_prime_bits}
@item tls_min_dh_prime_bits [@var{bits}]
@cmindex tls_min_dh_prime_bits
Set or unset the minimum number of Diffie-Hellman (DH) prime bits accepted for
TLS sessions. The default is set by the TLS library and can be selected by
using an empty argument to this command. Only lower the default (for example to
512 bits) if there is no other way to make TLS work with the remote server.
@anchor{tls_priorities}
@item tls_priorities [@var{priorities}]
@cmindex tls_priorities
Set the priorities for TLS sessions. The default is set by the TLS library and
can be selected by using an empty argument to this command.
See the GnuTLS documentation of the @samp{gnutls_priority_init} function for a
description of the @var{priorities} string.
@anchor{tls_host_override}
@item tls_host_override [@var{host}]
@cmindex tls_host_override
By default, TLS host verification uses the host name given by the @samp{host} command.
This command allows to use a different host name for verification. This is only
useful in special cases.
@end table

@section Commands specific to sendmail mode

@xref{Sendmail mode}.

@table @samp
@anchor{from}
@item from [@var{address}]
@cmindex from
Set the envelope-from address. The following substitution patterns are supported:
@itemize
@item @code{%U} will be replaced by @code{$USER}, or if that fails by @code{$LOGNAME}, or if that fails by
the login name of the user running msmtp.
@item @code{%H} will be replaced by @code{$HOSTNAME}, or if that fails by the host name of the system.
@item @code{%C} will be replaced by the canonical name of @code{%H}.
@item @code{%M} will be replaced by the contents of @code{/etc/mailname} (potentially a different
directory is used depending on the build configuration; see the output of
@samp{msmtp --version} and look for the location of the system configuration file).
@end itemize
Note that the obsolete @samp{auto_from} command replaces this envelope-from address.
@xref{Envelope-from address}.
@anchor{dsn_notify}
@item dsn_notify (off|@var{condition})
@cmindex dsn_notify
Set the condition(s) under which the mail system should send DSN (Delivery
Status Notification) messages. The argument @samp{off} disables explicit DSN
requests, which means the mail system decides when to send DSN messages. This
is the default.
The @var{condition} must be @samp{never}, to never request notification, or a
comma separated list (no spaces!) of one or more of the following:
@samp{failure}, to request notification on transmission failure, @samp{delay},
to be notified of message delays, @samp{success}, to be notified of successful
transmission. The SMTP server must support the DSN extension.
@xref{Delivery Status Notifications}.
@anchor{dsn_return}
@item dsn_return (off|@var{amount})
@cmindex dsn_return
This command controls how much of a mail should be returned in DSN (Delivery
Status Notification) messages. The argument @samp{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 @var{amount} must be @samp{headers}, to just return the message headers, or
@samp{full}, to return the full mail.
The SMTP server must support the DSN extension.
@xref{Delivery Status Notifications}.
@anchor{set_from_header}
@item set_from_header [(auto|on|off)]
@cmindex set_from_header
When to set a From header: @samp{auto} adds a From header if the mail does not
have one (this is the default), @samp{on\} always sets a From header and overrides
any existing one, and @samp{off} never sets a From header.@*
If the mail server rejects the mail because its From header does not match the
envelope from address (a common anti-spam measure), then you might want to set
this option to @samp{on}.@*
For compatibility with older versions, @samp{add_missing_from_header [(on|off)]}
is still supported and corresponds to the @samp{auto} and @samp{off} settings.@*
@xref{Header handling}.
@anchor{set_date_header}
@item set_date_header [(auto|off)]
@cmindex set_date_header
When to set a Date header: @samp{auto} adds a Date header if the mail does not
have one (this is the default), and @samp{off} never sets a Date header.@*
For compatibility with older versions, @samp{add_missing_date_header [(on|off)]}
is still supported and corresponds to the @samp{auto} and @samp{off} settings.@*
@xref{Header handling}.
@anchor{remove_bcc_headers}
@item remove_bcc_headers [(on|off)]
@cmindex remove_bcc_headers
This command controls whether to remove Bcc headers. The default is to remove them.
@xref{Header handling}.
@anchor{logfile}
@item logfile [@var{file}]
@cmindex logfile
Enable logging to the specified file. An empty argument disables logging. The
file name @samp{-} directs the log information to standard output.
@xref{Logging}.
@anchor{logfile_time_format}
@item logfile_time_format [@var{fmt}]
@cmindex logfile_time_format
Set or unset the log file time format. This will be used as the format string
for the strftime() function. An empty argument chooses the default
(@samp{"%b %d %H:%M:%S"}).
@xref{Logging}.
@anchor{syslog}
@item syslog [(on|off|@var{facility})]
@cmindex syslog
Enable or disable syslog logging. The @var{facility} can be one of
@samp{LOG_USER}, @samp{LOG_MAIL}, @samp{LOG_LOCAL0}, @dots{}, @samp{LOG_LOCAL7}.
The default is @samp{LOG_USER}. Syslog logging is disabled by default.
@xref{Logging}.
@anchor{aliases}
@item aliases [@var{file}]
@cmindex aliases
Replace local recipients with addresses in the aliases file. The aliases file
is a cleartext file containing mappings between a local address and a list of
replacement addresses. The mappings are of the form:
@example
local: someone@@example.com, person@@domain.example
@end example
Multiple replacement addresses are separated with commas. Comments start with '#'
and continue to the end of the line.@*
The local address @samp{default} has special significance and is matched if the
local address is not found in the aliases file. If no @samp{default} alias is
found, then the local address is left as is.@*
An empty argument to the aliases command disables the replacement of local
addresses. This is the default.
@anchor{auto_from}
@item auto_from [(on|off)]
@cmindex auto_from
Obsolete; you can achieve the same and more using the substitution patterns of the
@samp{from} command.@*
Enable or disable automatic envelope-from addresses. The default is @samp{off}.
When enabled, an envelope-from address of the form user@@domain will be
generated. The local part will be set to @code{USER} or, if that fails, to
@code{LOGNAME} or, if that fails, to the login name of the current user. The
domain part can be set with the @samp{maildomain} command; if that is empty,
the address not have a domain part.
@xref{Envelope-from address}.
@anchor{maildomain}
@item maildomain [@var{domain}]
@cmindex maildomain
Obsolete; you can achieve the same and more using the substitution patterns of the
@samp{from} command.@*
Set a domain part for the generation of an envelope-from address. See @ref{auto_from}.
@end table


@node Invocation
@chapter Invocation

@section Synopsis

@itemize
@item Sendmail mode (default):@*
@code{msmtp [@var{option}@dots{}] [--] @var{recipient}@dots{}}@*
@code{msmtp [@var{option}@dots{}] -t [--] [@var{recipient}@dots{}]}
@item Configuration mode:@*
@code{msmtp --configure @var{mailaddress}}@*
@item Server information mode:@*
@code{msmtp [@var{option}@dots{}] --serverinfo}
@item Remote Message Queue Starting mode:@*
@code{msmtp [@var{option}@dots{}]
--rmqs=(@var{host}|@var{@@domain}|@var{#queue})}
@end itemize

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

@subsection General options
@table @samp
@item --version
@opindex --version
Print version information, including information about the libraries used.
@item --help
@opindex --help
Print help.
@item -P
@itemx --pretend
@opindex -P
@opindex --pretend
Print the configuration settings that would be used, but do not take further
action. An asterisk ('*') will be printed instead of the password.
@item -v
@item -d
@itemx --debug
@opindex -v
@opindex -d
@opindex --debug
Print lots of debugging information, including the whole conversation with the
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!
@end table

@subsection Changing the mode of operation
@table @samp
@anchor{--configure}
@item --configure=@var{mailaddress}
@opindex --configure
Generate a configuration for the given mail address and print it. This can be
modified or copied unchanged to the configuration file.
Note that this only works for mail domains that publish appropriate SRV records;
see RFC 8314.
@anchor{--serverinfo}
@item -S
@itemx --serverinfo
@opindex -S
@opindex --serverinfo
Print information about the SMTP server and exit. This includes information
about supported features (mail size limit, authentication, TLS, DSN, @dots{})
and about the TLS certificate (if TLS is active).
@xref{Server information mode}.
@anchor{--rmqs}
@item --rmqs=(@var{host}|@var{@@domain}|@var{#queue})
@opindex --rmqs
Send a Remote Message Queue Starting request for the given host, domain, or
queue to the SMTP server and exit.
@xref{Remote Message Queue Starting mode}.
@end table

@subsection Configuration options
Most options in this category correspond to a configuration file command.
Please refer to @ref{Configuration files} for detailed information.
@table @samp
@item -C @var{filename}
@itemx --file=@var{filename}
@opindex -C
@opindex --file
Use the given file instead of @code{~/.msmtprc} or
@code{XDG_CONFIG_HOME/msmtp/config} as the user configuration file.
@item -a @var{account}
@itemx --account=@var{account}
@opindex -a
@opindex --account
Use the given account instead of the account named @samp{default}. This option
cannot be used together with the @option{--host} option.
@xref{Choosing an account}.
@item --host=@var{hostname}
@opindex --host
Use this server with settings from the command line; do not use any
configuration file data. This option cannot be used together with the
@option{--account} option. It disables loading of configuration files.
@xref{Choosing an account}.
@item --port=@var{number}
@opindex --port
Set the port number to connect to. @xref{port}.
@item --source-ip=[@var{IP}]
@opindex --source-ip
Set or unset an IP address to bind the socket to. @xref{source_ip}.
@item --proxy-host=[@var{IP}|@var{hostname}]
@opindex --proxy-host
Set or unset a SOCKS proxy to use. @xref{proxy_host}.
@item --proxy-port=[@var{number}]
@opindex --proxy-port
Set or unset a port number for the proxy host. @xref{proxy_port}.
@item --socket=[@var{socketname}]
@opindex --socket
Set or unset a local unix domain socket name to connect to. @xref{socket}.
@item --timeout=(off|@var{seconds})
@opindex --timeout
Set or unset a network timeout, in seconds. @xref{timeout}.
@item --protocol=(smtp|lmtp)
@opindex --protocol
Set the protocol. @xref{protocol}.
@item --domain=[@var{argument}]
@opindex --domain
Set the argument of the SMTP EHLO (or LMTP LHLO) command. @xref{domain}.
@anchor{--auth}
@item --auth[=(on|off|@var{method})]
@opindex --auth
Enable or disable authentication and optionally choose the method. @xref{auth}.
@anchor{--user}
@item --user=[@var{username}]
@opindex --user
Set or unset the user name for authentication. @xref{user}.
@anchor{--passwordeval}
@item --passwordeval=[@var{eval}]
@opindex --passwordeval
Evaluate password for authentication. @xref{passwordeval}.
@item --tls[=(on|off)]
@opindex --tls
Enable or disable TLS/SSL. @xref{tls}.
@anchor{--tls-starttls}
@item --tls-starttls[=(on|off)]
@opindex --tls-starttls
Enable or disable STARTTLS for TLS. @xref{tls_starttls}.
@anchor{--tls-trust-file}
@item --tls-trust-file=[@var{file}]
@opindex --tls-trust-file
Set or unset a trust file for TLS. @xref{tls_trust_file}.
@anchor{--tls-crl-file}
@item --tls-crl-file=[@var{file}]
@opindex --tls-crl-file
Set or unset a certificate revocation list (CRL) file for TLS.
@xref{tls_crl_file}.
@anchor{--tls-fingerprint}
@item --tls-fingerprint=[@var{fingerprint}]
@opindex --tls-fingerprint
Set ot unset the fingerprint of a trusted TLS certificate.
@xref{tls_fingerprint}.
@anchor{--tls-key-file}
@item --tls-key-file=[@var{file}]
@opindex --tls-key-file
Set or unset a key file for TLS. @xref{tls_key_file}.
@anchor{--tls-cert-file}
@item --tls-cert-file=[@var{file}]
@opindex --tls-cert-file
Set or unset a cert file for TLS. @xref{tls_cert_file}.
@anchor{--tls-certcheck}
@item --tls-certcheck[=(on|off)]
@opindex --tls-certcheck
Enable or disable server certificate checks for TLS.
@xref{tls_certcheck}.
@anchor{--tls-min-dh-prime-bits}
@item --tls-min-dh-prime-bits=[@var{bits}]
@opindex --tls-min-dh-prime-bits
Set or unset minimum bit size of the Diffie-Hellman (DH) prime.
@xref{tls_min_dh_prime_bits}.
@anchor{--tls-priorities}
@item --tls-priorities=[@var{priorities}]
@opindex --tls-priorities
Set or unset TLS priorities. @xref{tls_priorities}.
@anchor{--tls-host-override}
@item --tls-host-override=[@var{host}]
@opindex --tls-host-override
Set or unset override for TLS host verification. @xref{tls_host_override}.
@end table

@subsection Options specific to sendmail mode
@table @samp
@anchor{--from}
@item -f @var{address}
@itemx --from=@var{address}
@opindex -f
@opindex --from
Set the envelope-from address. @xref{from}.@*
If no account was chosen yet (with @option{--account} or @option{--host}), this
option will choose the first account that has the given envelope-from address
(set with the @samp{from} command). If no such account is found, "default" is
used. @xref{Choosing an account}.@*
See the @samp{from} command for substitution patterns supported in @var{address}.
@anchor{--dsn-notify}
@item -N (off|@var{condition})
@itemx --dsn-notify=(off|@var{condition})
@opindex -N
@opindex --dsn-notify
Set or unset DSN notification conditions. @xref{dsn_notify}.
@anchor{--dsn-return}
@item -R (off|@var{amount})
@itemx --dsn-return=(off|@var{amount})
@opindex -R
@opindex --dsn-return
Set or unset the DSN notification amount. @xref{dsn_return}.
Note that @samp{hdrs} is accepted as an alias for @samp{headers} to be
compatible with sendmail.
@anchor{--set-from-header}
@item --set-from-header[=(auto|on|off)]
@opindex --set-from-header
Set From header handling. @xref{set_from_header}.
@anchor{--set-date-header}
@item --set-date-header[=(auto|off)]
@opindex --set-date-header
Set Date header handling. @xref{set_date_header}.
@anchor{--remove-bcc-headers}
@item --remove-bcc-headers[=(on|off)]
@opindex --remove-bcc-headers
Enable or disable the removal of Bcc headers. @xref{remove_bcc_headers}.
@anchor{--logfile}
@item -X [@var{file}]
@itemx --logfile=[@var{file}]
@opindex -X
@opindex --logfile
Set or unset the log file. @xref{logfile}.
@anchor{--logfile-time-format}
@item --logfile-time-format=[@var{fmt}]
@opindex --logfile-time-format
Set or unset the log file time format. @xref{logfile_time_format}.
@anchor{--syslog}
@item --syslog[=(on|off|@var{facility})]
@opindex --syslog
Enable or disable syslog logging. @xref{syslog}.
@item -t
@itemx --read-recipients
@opindex -t
@opindex --read-recipients
Send the mail to the recipients given in the To, Cc, and Bcc headers of the
mail in addition to the recipients given on the command line.@*
If any Resent- headers are present, then the addresses from any Resent-To,
Resent-Cc, and Resent-Bcc headers in the first block of Resent- headers are
used instead.
@item --read-envelope-from
@opindex --read-envelope-from
Read the envelope from address from the From header of the mail.
@item --aliases=[@var{file}]
@opindex --aliases
Set or unset an aliases file. @xref{aliases}.
@item -F@var{name}
Msmtp adds a From header to mails that lack it, using the envelope from
address. This option allows to set a full name to be used in that header.
@anchor{--auto-from}
@item --auto-from[=(on|off)]
@opindex --auto-from
Obsolete. @xref{auto_from}.
@anchor{--maildomain}
@item --maildomain=[@var{domain}]
@opindex --maildomain
Obsolete. @xref{maildomain}.
@item --
This marks the end of options. All following arguments will be treated as
recipient addresses, even if they start with a '-'.
@end table

The following options are accepted but ignored for sendmail compatibility:
@samp{-B@var{type}}, @samp{-bm}, @samp{-G}, @samp{-hN},
@samp{-i}, @samp{-L @var{tag}}, @samp{-m}, @samp{-n},
@samp{-O option=@var{value}}, @samp{-ox @var{value}}

@anchor{Choosing an account}
@section Choosing an account

There are three ways to choose the account to use.

@enumerate
@item @option{--account=@var{account}}@*
Use the given account. Command line settings override configuration file
settings.
@item @option{--host=@var{hostname}}@*
Use only the settings from the command line; do not use any configuration file
data.
@item @option{--from=@var{address}} or @option{--read-envelope-from}@*
Choose the first account from the system or user configuration file that has
a matching envelope-from address as specified by a @ref{from} command. This
works only when neither @option{--account} nor @option{--host} is used.
@end enumerate
If none of the above options is used (or if no account has a matching
@ref{from} command), then the account "default" is used.

@section Exit code

The standard exit codes from @code{sysexits.h} are used.

@anchor{Files}
@section Files

@table @samp
@item @code{SYSCONFDIR/msmtprc}
The system configuration file. Use the @option{--version} option to find out what
@code{SYSCONFDIR} is on your platform.
@item @code{~/.msmtprc} or @code{$XDG_CONFIG_HOME/msmtp/config}.
The default user configuration file.
@item @code{~/.netrc} and @code{SYSCONFDIR/netrc}
The @code{netrc} file contains login information. Before prompting for a
password, msmtp will search it in ~/.netrc and SYSCONFDIR/netrc.
@end table

@anchor{Environment}
@section Environment

@table @samp
@item @code{USER}, @code{LOGNAME}
These variables override the user's login name when constructing an
envelope-from address. @code{LOGNAME} is only used if @code{USER} is unset.
@item @code{TMPDIR}
Directory to create temporary files in. If this is unset, a system specific
default directory is used. A temporary file is used to buffer the headers of
the mail but not the mail body, so the file will not get very large.
@item @code{EMAIL}, @code{SMTPSERVER}
These environment variables are used only if neither @option{--host} nor
@option{--account} is used and there is no default account defined in the
configuration files. In this case, the host name is taken from
@code{SMTPSERVER}, and the envelope from address is taken from @code{EMAIL},
unless overridden by @option{--from} or @option{--read-envelope-from}. Currently
@code{SMTPSERVER} must contain a plain host name (no URL), and @code{EMAIL}
must contain a plain address (no names or additional information).
@end table

@node Transport Layer Security
@chapter Transport Layer Security

Transport Layer Security (TLS)
"@dots{} provides communications privacy over the Internet.  The protocol
allows client/server applications to communicate in a way that is designed to
prevent eavesdropping, tampering, or message forgery" (quote from RFC2246).

A server can use TLS in one of two modes:
@itemize
@item Via a STARTTLS command@*
The session starts with the normal protocol initialization, and TLS is then
started using the protocol's STARTTLS command.
@item Immediately@*
TLS is initialized before the normal protocol initialization. This requires a
separate port.
@end itemize
The first mode is the default, but you can switch to the second mode by disabling
@ref{tls_starttls}.

When TLS is started, the server sends a certificate to identify itself. To
verify the server identity, a client program is expected to check that the
certificate is formally correct and that it was issued by a Certificate
Authority (CA) that the user trusts. (There can also be certificate chains with
intermediate CAs.)

The list of trusted CAs is specified using the @ref{tls_trust_file} command.
The default value ist @samp{system} and chooses the system-wide default, but you can
also choose the trusted CAs yourself.

One practical problem with this approach is that the client program should also
check if the server certificate has been revoked for some reason, using a
Certificate Revocation List (CRL). A CRL file can be specified using the
@ref{tls_crl_file} command, but getting the relevant CRL files and keeping them
up to date is not straightforward. You are basically on your own.

A much more serious and fundamental problem is that you need to trust CAs.
Like any other organization, a CA can be incompetent, malicious, subverted by
bad people, or forced by government agencies to compromise end users without
telling them. All of these things happened and continue to happen worldwide.
The idea to have central organizations that have to be trusted for your
communication to be secure is fundamentally broken.

Instead of putting trust in a CA, you can choose to trust only a single
certificate for the server you want to connect to. For that purpose, specify
the certificate fingerprint with @ref{tls_fingerprint}. This makes sure that no
man-in-the-middle can fake the identity of the server by presenting you a
fraudulent certificate issued by some CA that happens to be in your trust list.
However, you have to update the fingerprint whenever the server certificate
changes, and you have to make sure that the change is legitimate each time,
e.g. when the old certificate expired. This is inconvenient, but it's the price
to pay.

Information about a server certificate can be obtained with @samp{--serverinfo
--tls --tls-certcheck=off}. This includes the issuer CA of the certificate (so
you can trust that CA via @samp{tls_trust_file}), and the fingerprint of the
certificate (so you can trust that particular certificate via
@samp{tls_fingerprint}).
@xref{Server information mode}.

If you need to fine tune TLS parameters, have a look at the
@ref{tls_priorities} and @ref{tls_min_dh_prime_bits} commands.

@anchor{Client Certificates}
@section Client Certificates

TLS also allows the server to verify the identity of the client. For this
purpose, the client has to present a certificate issued by a CA that the server
trusts. To present that certificate, the client also needs the matching key
file. You can set the certificate and key files using @ref{tls_cert_file} and
@ref{tls_key_file}. This mechanism can also be used to authenticate users, so
that traditional user / password authentication is not necessary anymore. See the
EXTERNAL mechanism in @ref{Authentication}.

@example
# Enable TLS
tls on
# Enable TLS client certificates
tls_cert_file /path/to/client_cert
tls_key_file /path/to/client_key
# Enable authentication via the EXTERNAL mechanism (optional; depends on server)
# The user name is empty because the server should get it from the client cert
auth external
user ""
@end example

You can also use client certificates stored on some external authentication
device by specifying GnuTLS device URIs in @ref{tls_cert_file} and
@ref{tls_key_file}. You can find the correct URIs using @code{p11tool
--list-privkeys --login} (p11tool is bundled with GnuTLS). If your device
requires a PIN to access the data, you can specify that using one of the
password mechanisms (e.g. @ref{passwordeval}, @ref{password}). 

@example
tls_cert_file pkcs11:model=PKCS%2315%20emulated;manufacturer=piv_II;serial=00000000;token=PIV_II%20%28PIV%20Card%20Holder%20pin%29;id=%01;object=Certificate%20for%20PIV%20Authentication;type=cert
tls_key_file  pkcs11:model=PKCS%2315%20emulated;manufacturer=piv_II;serial=00000000;token=PIV_II%20%28PIV%20Card%20Holder%20pin%29;id=%01;object=PIV%20AUTH%20key;type=private
passwordeval  gpg2 --no-tty -q -d ~/.smart-card-pin.gpg
@end example


@node Authentication
@chapter Authentication

Many SMTP servers require a client to authenticate before sending mail.

Usually a user name and a password are used for authentication. The user name
specified in the configuration file with the @ref{user} command. There are five
different methods to specify the password:
@enumerate
@item Add the password to the system key ring.@*
Currently supported key rings are the Gnome key ring and the Mac OS X Keychain.
For the Gnome key ring, use the command @samp{secret-tool} (part of Gnome's
libsecret) to store passwords:
@example
$ secret-tool store --label=msmtp \
  host mail.freemail.example \
  service smtp \
  user joe.smith
@end example
On Mac OS X, use the following command:
@example
security add-internet-password -s mail.freemail.example -r smtp -a joe.smith -w
@end example
In both examples, replace mail.freemail.example with the SMTP server name, and
joe.smith with your user name.
@item Store the password in an encrypted files, and use @ref{passwordeval}
to specify a command to decrypt that file, e.g. using GnuPG. @xref{Examples}.
@item Store the password in the configuration file using the @ref{password} command.
(Usually it is not considered a good idea to store passwords in cleartext files.
If you do it anyway, you must make sure that the file can only be read by yourself.)
@item Store the password in @file{~/.netrc}. This method is probably obsolete.
@item Type the password into the terminal when it is required.
@end enumerate
It is recommended to use method 1 or 2.

Multiple authentication methods exist. Most servers support only some of them.
Historically, sophisticated methods were developed to protect passwords from
being sent unencrypted to the server, but nowadays everybody needs
@ref{Transport Layer Security} anyway, so the simple methods suffice since the
whole session is protected. A suitable authentication method is chosen
automatically, and when TLS is disabled for some reason, only methods that avoid
sending cleartext passwords are considered.

The following user / password methods are supported:
@itemize
@item @samp{PLAIN}@*
A simple cleartext method supported by almost all servers.
@item @samp{SCRAM-SHA-1}@*
A method that avoids cleartext passwords.
@item @samp{CRAM-MD5}@*
An obsolete method that avoids cleartext passwords, but is not considered
secure anymore.
@item @samp{DIGEST-MD5}@*
An overcomplicated obsolete method that avoids cleartext passwords, but is not
considered secure anymore.
@item @samp{LOGIN}@*
A non-standard cleartext method similar to (but worse than) PLAIN.
@item @samp{NTLM}@*
An obscure non-standard method that is now considered broken. It sometimes requires
a special domain parameter passed via @ref{ntlmdomain}. Do not use it.
@end itemize

There are currently three authentication methods that are not based on user /
password information and have to be chosen manually:
@itemize
@item @samp{OAUTHBEARER}@*
An OAuth2 token from the mail provider is used as the password.
See the documentation of your mail provider for details on how to get this
token. The @samp{passwordeval} command can be used to pass the regularly changing
tokens into msmtp from a script or an environment variable.
@item @samp{EXTERNAL}@*
The authentication happens outside of the protocol, typically by sending a TLS
client certificate (see @ref{Client Certificates}).@*
The EXTERNAL method merely confirms that this authentication succeeded; it does
not perform the authentication. Thus it may not be necessary to use it for
authentication to succeed, and if the server does not support the EXTERNAL
method, this does not mean that it does not support authentication with TLS
client certificates.
@item @samp{GSSAPI}@*
With this method, the Kerberos framework takes care of secure authentication.
Only a user name is required.
@end itemize

It depends on the underlying authentication library and its version whether a
particular method is supported or not. Use @option{--version} to find out which
methods are supported by your version.


@node Delivery Status Notifications
@chapter Delivery Status Notifications

In situations such as delivery failure or delay, the mail system usually
generates a message for the sender of the mail, informing him about the
difficulties.

Delivery Status Notification (DSN) requests, defined in RFC 3461, try to give
the sender of the mail control about how and when these DSN messages are sent.
The SMTP server must support the DSN extension. @xref{Server information mode}.

A first parameter controls when such messages should be generated:
never, on delivery failure, on delivery delay, and/or on success.
This can be set with @ref{dsn_notify} and @ref{--dsn-notify}.

A second parameter controls how much of the original mail should be contained
in a DSN message: only the headers, or the full mail. This can be set with
@ref{dsn_return} and @ref{--dsn-return}.
Note that this parameter only applies to DSNs that indicate delivery failure
for at least one recipient. If a DSN contains no indications of delivery
failure, only the headers of the message are returned.


@node Sendmail mode
@chapter Sendmail mode

@menu
* Envelope-from address::	Information about envelope-from addresses
* Logging::			Different logging methods
* Header handling::		Modifications to mail headers
@end menu

@node Envelope-from address
@section Envelope-from address

The SMTP server expects a sender mail address for each mail. This is the
envelope-from address. It is independent of the From header (because it is
part of the mail @emph{envelope}, not of the mail itself), but in most cases
both addresses are the same.

Envelope-from addresses are set with the @ref{from} command, which allows
automatisms using some substitution patterns.

@node Logging
@section Logging

When logging is enabled, msmtp will generate one log line for each mail it
tries to send.

The line will include the following information:
@itemize
@item Host name of the SMTP server:  @code{host=hostname}
@item Whether TLS was used: @code{tls=(on|off)}
@item Whether authentication was used: @code{auth=(on|off)}
@item The user name used for authentication (only if authentication is used):
@code{user=name}
@item The envelope-from address: @code{from=address}
@item The recipient addresses: @code{recipients=addr1,addr2,@dots{}}
@item The size of the mail as transferred to the server, in bytes (only if the
delivery succeeded): @code{mailsize=number}
@item The SMTP status code and SMTP error message (only in case of
failure and only if available): @code{smtpstatus=number},
@code{smtpmsg='message'}. Multiline SMTP messages will be concatenated into one
line.
@item The msmtp error message (only in case of failure and only
if available): @code{errormsg='message'}
@item The msmtp exit code (from @code{sysexits.h}; @samp{EX_OK} indicates
success): @code{exitcode=EX_@dots{}}
@end itemize

If a logfile is given with the @ref{logfile} command, this log line will be
prepended with the current date and time (formatted according to
@ref{logfile_time_format}) and appended to the specified file.

If syslog logging is enabled with the @ref{syslog} command, the log line is
passed to the syslog service with the specified facility.


@node Header handling
@section Header handling

Msmtp transmits mails unaltered to the SMTP server, with the following exceptions:
@itemize
@item The Bcc header(s) will be removed. This behavior can be changed with the
@ref{remove_bcc_headers} command,
@item A From header will be added if the mail does not have one. This can be changed
with the @ref{set_from_header} command.
The header will use the envelope from address and optionally a full name set
with the @samp{-F} option.
@item A Date header will be added if the mail does not have one. This can be changed
with the @ref{set_date_header} command.
@end itemize


@node Server information mode
@chapter Server information mode

In server information mode, msmtp prints as much information about the SMTP
server as it can get and then exits.

The SMTP features that can be detected are:
@itemize
@item SIZE@*
The maximum message size that the SMTP server accepts.
@item PIPELINING@*
Whether certain SMTP commands may be send in groups rather than one by one.
This can speed up mail transmission if the recipient list is long.
This feature is used automatically.
@item STARTTLS@*
@xref{Transport Layer Security}.
@item AUTH@*
@xref{Authentication}.
@item DSN@*
@xref{Delivery Status Notifications}.
@item ETRN@*
@xref{Remote Message Queue Starting mode}.
@end itemize

If TLS is activated for server information mode, the following information will
be printed about the SMTP server's TLS certificate (if available):
@itemize
@item Owner information
@itemize
@item Common Name
@item Organization
@item Organizational unit
@item Locality
@item State or Province
@item Country
@end itemize
@item Issuer information
@itemize
@item Common Name
@item Organization
@item Organizational unit
@item Locality
@item State or Province
@item Country
@end itemize
@item General
@itemize
@item Activation time
@item Expiration time
@item SHA256 fingerprint
@item SHA1 fingerprint (deprecated)
@end itemize
@end itemize


@node Remote Message Queue Starting mode
@chapter Remote Message Queue Starting mode

Remote Message Queue Starting (RMQS) is defined in RFC 1985.  It is a way for a
client to request that a server start the processing of its mail queues for
messages that are waiting at the server for the client machine.  If any
messages are at the server for the client, then the server creates a new SMTP
session and sends the messages at that time.

msmtp can only send the request (using the ETRN SMTP command); a mail server on
the client side should then accept the connection of the remote SMTP server to
receive the mail.

RMQS requests can be sent with the @ref{--rmqs} option.
Destinations defined in RFC 1985 are:
@itemize
@item @var{host}@*
Request the messages for the given host.
@item @var{@@domain}@*
Request the messages for the given domain.
@item @var{#queue}@*
Request the delivery of the messages in the given queue.
@end itemize


@node Examples
@chapter Examples

@menu
* A user configuration file::
* A system wide configuration file::
* Using msmtp with Mutt::
* Using msmtp with mail::
* Using msmtp with Tor::
* Aliases file::
@end menu

@node A user configuration file
@section A user configuration file

@example
# Example for a user configuration file ~/.msmtprc
#
# This file focusses on TLS and authentication. Features not used here include
# logging, timeouts, SOCKS proxies, TLS parameters, Delivery Status Notification
# (DSN) settings, and more.


# Set default values for all following accounts.
defaults

# Use the mail submission port 587 instead of the SMTP port 25.
port 587

# Always use TLS.
tls on

# Set a list of trusted CAs for TLS. The default is to use system settings, but
# you can select your own file.
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
# If you select your own file, you should also use the tls_crl_file command to
# check for revoked certificates, but unfortunately getting revocation lists and
# keeping them up to date is not straightforward.
#tls_crl_file ~/.tls-crls


# A freemail service
account freemail

# Host name of the SMTP server
host smtp.freemail.example

# As an alternative to tls_trust_file/tls_crl_file, you can use tls_fingerprint
# to pin a single certificate. You have to update the fingerprint when the
# server certificate changes, but an attacker cannot trick you into accepting
# a fraudulent certificate. Get the fingerprint with
# $ msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.freemail.example
#tls_fingerprint 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33

# Envelope-from address
from joe_smith@@freemail.example

# Authentication. The password is given using one of five methods, see below.
auth on
user joe.smith

# Password method 1: Add the password to the system keyring, and let msmtp get
# it automatically. To set the keyring password using Gnome's libsecret:
# $ secret-tool store --label=msmtp \
#   host smtp.freemail.example \
#   service smtp \
#   user joe.smith

# Password method 2: Store the password in an encrypted file, and tell msmtp
# which command to use to decrypt it. This is usually used with GnuPG, as in
# this example. Usually gpg-agent will ask once for the decryption password.
passwordeval gpg2 --no-tty -q -d ~/.msmtp-password.gpg

# Password method 3: Store the password directly in this file. Usually it is not
# a good idea to store passwords in cleartext files. If you do it anyway, at
# least make sure that this file can only be read by yourself.
#password secret123

# Password method 4: Store the password in ~/.netrc. This method is probably not
# relevant anymore.

# Password method 5: Do not specify a password. Msmtp will then prompt you for
# it. This means you need to be able to type into a terminal when msmtp runs.


# A second mail address at the same freemail service
account freemail2 : freemail
from joey@@freemail.example


# The SMTP server of your ISP
account isp
host mail.isp.example
from smithjoe@@isp.example
auth on
user 12345


# Set a default account
account default : freemail
@end example

@node A system wide configuration file
@section A system wide configuration file

@example
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default

# The SMTP smarthost
host mail.oursite.example

# Use TLS on port 465
port 465
tls on
tls_starttls off

# Construct envelope-from addresses of the form "user@@oursite.example"
from %U@@oursite.example

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL
@end example


@node Using msmtp with Mutt
@section Using msmtp with Mutt

Create a configuration file for msmtp and add the following lines to your Mutt
configuration file:
@example
set sendmail="/path/to/msmtp"
set use_from=yes
set realname="Your Name"
set from=you@@example.com
set envelope_from=yes
@end example

The @samp{envelope_from=yes} option lets Mutt use the @option{-f} option of
msmtp.	Therefore msmtp chooses the first account that matches the from address
you@@example.com. Alternatively, you can use the @option{-a} option:
@example
set sendmail="/path/to/msmtp -a my_account"
@end example

Or set everything from the command line:
@example
set sendmail="/path/to/msmtp --host=mailhub -f me@@example.com --tls"
@end example
@xref{Choosing an account}.

If you have multiple mail accounts in your msmtp configuration file and let Mutt
use the @option{-f} option to choose one, you can easily switch accounts in Mutt
with the following Mutt configuration lines:
@example
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"
@end example
Now you can use <esc>1, <esc>2, and <esc>3 to switch accounts.

The following example uses a different approach: it maps the single key
@code{<tab>} in Compose context for switching between the various account in a
handy visual way. In the same Compose context, @code{=} is mapped in order to
show the current msmtp account. This example was contributed by Thomas Baruchel.
@example
# Define <tab> and = in order to switch or see the current msmtp account
# Don't forget to put the right path for msmtp binary
macro compose \Cx_ ":set sendmail"
macro compose \Cx| "\Cx_ = \"/usr/local/bin/msmtp"
macro compose \Cx& ":macro compose \\t \\Cx"
macro compose <tab> "\Cx0"
macro compose = "\Cx_\n"
# Put the account in the following lines (here three accounts)
# Don't forget to put the number of the account at the beginning
# of the line, and the number of the next account after the '&'
macro compose \Cx0 "\Cx|\"\n\Cx&1\n\Cx_\n" # default and switch to 1
macro compose \Cx1 "\Cx| -a example_account\"\n\Cx&2\n\Cx_\n" # switch to 2
macro compose \Cx2 "\Cx| -a gmail\"\n\Cx&0\n\Cx_\n" # switch to 0
# End of the accounts
@end example

@node Using msmtp with mail
@section Using msmtp with mail

Define a default account, and put the following into @code{~/.mailrc}:
@example
set sendmail="/path/to/msmtp"
@end example

You need to define a default account, because mail does not allow extra options
to the msmtp command line.

@node Using msmtp with Tor
@section Using msmtp with Tor
Use the following settings:
@example
proxy_host 127.0.0.1
proxy_port 9050
tls on
@end example
Use an IP address as proxy host name, so that msmtp does not leak a DNS query
when resolving it.@*
TLS is required to prevent exit hosts from reading your SMTP session. You also
need @ref{tls_trust_file} or @ref{tls_fingerprint} to check the server
identity.
Do not set @samp{domain} to something that you do not want to reveal (do not set
it at all if possible).

@node Aliases file
@section Aliases file

@example
# Example aliases file

# Send root to Joe and Jane
root: joe_smith@@example.com, jane_chang@@example.com

# Send cron to Mark
cron: mark_jones@@example.com

# Send everything else to admin
default: admin@@domain.example
@end example

@node Minimal SMTP server (msmtpd)
@chapter Minimal SMTP server (msmtpd)

Msmtpd is a minimal SMTP server that pipes mails to msmtp (or some other program) for delivery.
It is intended to be used with system services that expect an SMTP server on the local host and
cannot be configured to use the sendmail interface that msmtp provides.

Msmtpd handles local SMTP clients. It listens on 127.0.0.1 port 25 by default, but can also run
without its own network sockets in inetd mode, where it handles a single SMTP session on
standard input / output.

In the string that defines the command that msmtpd pipes each mail to, the first occurrence of
@samp{%F} will be replaced with the envelope from address. Furthermore, all recipients of the
mail will be appended as arguments. The command must not write to standard output, as that would
mess up the SMTP session.

Only run msmtpd if you know you need it. Only use a local interface to listen on. Take care
to run it with correct user rights and permissions (e.g. use @samp{CAP_NET_BIND_SERVICE} to bind
to port 25 instead of running as root, or use systemd with inetd service
capabilities). Be aware that the pipe command will be run as the same user that
msmtpd runs as.

Msmtpd handles the following options:
@table @samp
@item --version
Print version information
@item --help
Print help.
@item --inetd
Start single SMTP session on stdin/stdout
@item --interface=@var{ip}
Listen on the given IPv6 or IPv4 address instead of 127.0.0.1
@item --port=@var{number}
Listen on the given port number instead of 25
@item --command=@var{cmd}
Pipe mails to @var{cmd} instead of msmtp
@end table

Example for managing msmtpd with @samp{start-stop-daemon}:
@example
# start msmtpd
start-stop-daemon --start --pidfile /var/run/msmtpd.pid --make-pidfile --chuid msmtpd --background --exec /usr/local/bin/msmtpd -- --command '/usr/local/bin/msmtp -f %F'
# stop msmtpd
start-stop-daemon --stop  --pidfile /var/run/msmtpd.pid --remove-pidfile --quiet --signal TERM
@end example

@bye
