Sending e-mails via mailbox.org with msmtp on Fedora
Since I run several ZFS pools and want to get a notification by the integrated daemon “zed” in case of an error, I had the idea to create an alias at my email provider mailbox.org and send these notifications to my private mailbox via this alias.
First, we need to install the msmtp
and s-nail
packages. This is a very lightweight SMTP client and a mailx
compatible mail processing system to be able to send emails later using the mail
command.
dnf install msmtp s-nail
After the installation, we copy the default configuration of msmtp into /etc
and adjust it according to our requirements.
cp /usr/share/doc/msmtp/msmtprc-system.example /etc/msmtprc
account default
host smtp.mailbox.org
port 587
tls on
tls_starttls on
auth plain
user <username@mailbox.org>
password <mailbox.org-password>
from sender@alias.tdl
allow_from_override off
set_from_header on
syslog LOG_MAIL
Now we have configured a system-wide SMTP account. However, not every user should be able to access the password. Therefore, we then adjust the permissions of the file.
chmod 600 /etc/msmtprc
Last but not least, we now define the MTA (Mail Transport Agent) so that s-nail uses the msmtp client.
set mta=/usr/bin/msmtp
With the help of the following command, we can now send a test mail. It shouldn’t generate any output.
echo 'Message body' | mail -s 'A subject' mail@example.com