As I described earlier, I’ve been using sSMTP for email support in Docker containers. Unfortunately, sSMTP is not maintained anymore. Instead msmtp should be used. I put the migration off for as long as possible, but eventually implemented the change!

For legacy reasons I will leave my orginal articles about sSMTP untouched (I’ll just add a link to this page), and instead post this migration how-to.

Given

Let’s assume we’ve been using the following sSMTP config in /etc/ssmtp/ssmtp.conf:

FromLineOverride=YES
mailhub=RELAY
hostname=HOSTNAME
UseTLS=YES
UseSTARTTLS=YES

In addition, we somewhere needed to tell the system/software/module how to send mails. For example, for PHP it would be somthing like that in /usr/local/etc/php/conf.d/mail.ini:

[mail function]
sendmail_path = "/usr/sbin/ssmtp -t"

Then

In that case you would need a msmtp configuration in /etc/msmtprc:

defaults
port 25
tls on

account default
auth off
host RELAY
domain HOSTNAME
from webserver@HOSTNAME
add_missing_date_header on

In addition, you need to tell the system/software/module send mails via /usr/bin/msmtp -t. For example, for PHP it would be somthing like that in /usr/local/etc/php/conf.d/mail.ini:

[mail function]
sendmail_path = "/usr/bin/msmtp -t"

Please note that msmtp is in /usr/bin not /usr/sbin !! ;-)

Supplemental Material

  • The paths mentioned above are target paths. Thus, if you’re using Docker it actually doesn’t matter where you store the files, but you need to mount them to those paths inside the container..
  • There are much more options for msmtp! You can also configure an actual mail account at Posteo or Google or wherever. I recommend checking its documentation and Arch’s Wiki.

Martin Scharm

stuff. just for the records.

Do you like this page?
You can actively support me!

Leave a comment

There are multiple options to leave a comment: