0

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
root=no-reply@domain.fr
mailhub=mail.infomaniak.com:587
AuthUser=no-reply@domain.fr
AuthPass=PASS
UseTLS=YES
UseSTARTTLS=YES
Debug=YES

Into revaliases i've got :

www-data:no-reply@domain.fr:mail.infomaniak.com:587
root:no-reply@domain.fr: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 "root=no-reply@domain.fr" >> /etc/ssmtp/ssmtp.conf \
&& echo "mailhub=mail.infomaniak.com:587" >> /etc/ssmtp/ssmtp.conf \
&& echo "AuthUser=no-reply@domain.fr" >> /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:no-reply@domain.fr: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 !

  • How did you configure the mail server inside the docker container? – Gerald Schneider Jan 04 '22 at 10:01
  • I've edited my original post with the content of my Dockerfile :) – Mathéo Tichy Jan 04 '22 at 10:16
  • SSMTP logs through syslog but you probably don't have it inside the docker container. – AlexD Jan 04 '22 at 10:26
  • @AlexD is there a possibility to have at least these logs ? What can i do ? I'm quite lost now – Mathéo Tichy Jan 04 '22 at 10:35
  • You can mount `/dev/log` from the host into the container. – AlexD Jan 04 '22 at 10:39
  • @AlexD Do you mean `/var/log` instead of `/dev/log` ? I don't have it in my container – Mathéo Tichy Jan 04 '22 at 10:42
  • I mean `/dev/log`. It is a socket used for `syslog` logging. – AlexD Jan 04 '22 at 10:46
  • @AlexD I have mount `/dev/log` on my container (`--mount type=bind,src=/dev/log,dst=/dev/log`) but there is no more logs. For the error that I can have in apache is : `sendmail: 550 5.7.1 Sender mismatch` – Mathéo Tichy Jan 04 '22 at 12:09
  • You should look for logs in your host `/var/log/mail.log`. – AlexD Jan 04 '22 at 12:13
  • Thanks @AlexD ! Logs are working, but the error is not very helpful... ```550 5.7.1 Sender mismatch Can't open /var/www/dead.letter failing horribly!``` I don't know if the second line is a warning or a real error – Mathéo Tichy Jan 04 '22 at 12:20
  • The message means that your target mail server (`mailhub=mail.infomaniak.com:587`) rejected the message with `550 5.7.1 Sender mismatch`. Also, `SSMTP` tried to save the message in `/var/www/dead.letter` but failed, probably due to file permissions. – AlexD Jan 04 '22 at 12:26

2 Answers2

0

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.

AlexD
  • 8,179
  • 2
  • 28
  • 38
0

I've solved my problem after a lot of work !

If you have the same problem, to activate logs I mount /dev/log and /var/www to the container.

The server had a problem while writing into /var/www/dead.letter so I've created this file and put 777 permissions (for the test).

And finally, to solve 550 5.7.1 Sender mismatch I asked to my email host to know what was the problem (I discovered that my email was blocked by their servers). And the problem (for Infomaniak.com) was that the sender and contact email was different than the domain used.

Thanks to every people that helped me !