How to set up MSMTP on Debian to use a mailhoster with SMTP

Tags: msmtp, mailhoster, linux, smtp, tls
Last update: Jul 2022

Tested with: Debian 11


First we need to install packages:

sudo apt install msmtp mailutils

Note: mailutils is needed for sending mail via “mail” on the command line.

Edit the global configuration file:

sudo nano /etc/msmtprc

Fill up the configuration file:

# Set default values for all accounts.
account default
auth            on
tls             on
tls_trust_file  /etc/ssl/certs/ca-certificates.crt

# netcup
host            <yourMailHost>
port            587
from            <mail@domain.tld>
user            <user>
password        <pass>

aliases         /etc/msmtp-aliases

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

Create the aliases file:

sudo nano /etc/msmtp-aliases

with the following content:

# Send root mails to
root: <yourAddress>

# Send cron mails to
cron: <yourAddress>

# Send everything else to admin
default: <yourAddress>

Create the mail.rc. file:

sudo nano /etc/mail.rc

and fill it up with:

set sendmail="/usr/bin/msmtp -t"

If you need to check the logs in case of troubleshooting:

sudo tail -f /var/log/mail.log



Change history

  • Jul 2022: creation
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *