|MSMTP(1)||General Commands Manual||MSMTP(1)|
The following options are accepted but ignored for sendmail
-Btype, -bm, -G, -hN, -i, -L tag, -m, -n, -O option=value, -ox value
The user can choose which account to use in one of three ways:
If none of the above options is used (or if no account has a matching from command), then the account "default" is used.
Msmtp transmits mails unaltered to the SMTP server, with the
- The Bcc header(s) will be removed. This behavior can be changed with the remove_bcc_headers command and --remove-bcc-headers option.
- A From header will be added if the mail does not have one. This can be changed with the set_from_header command and --set-from-header option. The header will use the envelope from address and optionally a full name set with the -F option.
- A Date header will be added if the mail does not have one. This can be changed with the set_date_header command and --set-date-header option.
- When undisclosed_recipients is set, the original To, Cc, and Bcc headers are removed and replaced with "To: undisclosed-recipients:;".
Skip to the EXAMPLES section for a quick start.
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 a file name starts with 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 are organized in accounts. Each account starts with the account command and defines the settings for one SMTP account.
Skip to the EXAMPLES section for a quick start.
Commands are as follows:
# 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.
# Use the mail submission port 587 instead of the SMTP port 25.
# Always use TLS.
# Set a list of trusted CAs for TLS. The default is to use system
# you can select your own file.
# A freemail service
# Host name of the SMTP server
# As an alternative to tls_trust_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
# Envelope-from address
# Authentication. The password is given using one of five methods,
# 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
# 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 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
# The SMTP server of your ISP
# Set a default account
account default : freemail
Using msmtp with Mutt
Create a configuration file for msmtp and add the following lines
to your Mutt configuration file:
set realname="Your Name"
The envelope_from=yes option lets Mutt use the -f option of msmtp. Therefore msmtp chooses the first account that matches the from address email@example.com.
Alternatively, you can use the -a option:
set sendmail="/path/to/msmtp -a my-account"
Or set everything from the command line (but note that you cannot set a password this way):
set sendmail="/path/to/msmtp --host=mailhub -f firstname.lastname@example.org --tls --tls-trust-file=trust.crt"
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 email@example.com"
macro generic "<esc>2" ":set firstname.lastname@example.org"
macro generic "<esc>3" ":set email@example.com"
Using msmtp with mail
Define a default account, and put the following in your ~/.mailrc:
Using msmtp with Tor
Use the following settings:
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.
Do not set domain to something that you do not want to reveal (do not set it at all if possible).
# Example aliases file
# Send root to Joe and Jane
root: firstname.lastname@example.org, email@example.com
# Send cron to Mark
# Send everything else to admin