SSMTP Not Working and Not Logging – Troubleshooting on Debian

debiansendmailssmtp

I've configured SSMTP to send mail, but the problem is that i can't send mail from my webserver and there is no logs in /var/log. Sometimes, i've got Sender mismatch in apache logs.

My config : Debian 11, and webserver into a Docker container.

This is my config of SSMTP :

hostname=domain.fr
[email protected]
mailhub=mail.infomaniak.com:587
[email protected]
AuthPass=PASS
UseTLS=YES
UseSTARTTLS=YES
Debug=YES

Into revaliases i've got :

www-data:[email protected]:mail.infomaniak.com:587
root:[email protected]:mail.infomaniak.com:587

EDIT : This is the part in my Dockerfile where I install and configure SSMTP :

&& apt -y install ssmtp mailutils \
&& echo "hostname=domain.fr" > /etc/ssmtp/ssmtp.conf \
&& echo "[email protected]" >> /etc/ssmtp/ssmtp.conf \
&& echo "mailhub=mail.infomaniak.com:587" >> /etc/ssmtp/ssmtp.conf \
&& echo "[email protected]" >> /etc/ssmtp/ssmtp.conf \
&& echo "AuthPass=" >> /etc/ssmtp/ssmtp.conf \
&& echo "UseTLS=YES" >> /etc/ssmtp/ssmtp.conf \
&& echo "UseSTARTTLS=YES" >> /etc/ssmtp/ssmtp.conf \
&& echo "Debug=YES" >> /etc/ssmtp/ssmtp.conf \
&& echo "www-data:[email protected]:mail.infomaniak.com:587" >> /etc/ssmtp/revaliases

For information, in CLI i can send emails while i'm on root account.

What could be my problem ?

Thanks for your help !

Best Answer

The message 550 5.7.1 Sender mismatch means that your target mail server (mailhub=mail.infomaniak.com:587) rejected a mail sent by SSMTP. Also, SSMTP tried to save the message in /var/www/dead.letter but failed, probably due to file permissions.

You need to check logs mail.infomaniak.com to find out why it is rejecting your emails. You can also check dead.letter to ensure that it contains correct headers. You'll need to set the home directory for the user SSMTP running as to a directory where it has write permissions.