Search code examples
dockersendmailssmtp

ssmtp in docker image


I'm trying to setup ssmtp (for sendmail) in Docker image.

To do so I've created the folowing Dockerfile:

FROM php:7.4-apache

# Install paquet requirements
RUN set -ex; \
    # Install required system packages
    apt-get update; \
    apt-get install -qy --no-install-recommends \
            ssmtp \
            mailutils \
    ; \
    # Clean aptitude cache and tmp directory
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;

As you can see I have installed ssmtp and mailutils.

My /etc/ssmtp.conf file contains all credentials that I can log into my account using standard mail client:

[email protected]

mailhub=mail.mydomain.com:587
[email protected]
AuthPass=PASS_HERE

FromLineOverride=YES

UseTLS=YES
#UseSTARTTLS=YES
Debug=YES

hostname=OVERRIDEN_HOSTNAME

From some reason mail is not sent. I'm tying with sendmail command:

sendmail [email protected]
Subject: aaa
aaa
CTRL+d

and getting error:

sendmail: Authorization failed (535 Incorrect authentication data)

Even Debug=YES is set, I do not see any log under /var/log regarding sendmail.

Do you have any thought what might be wrong?

Thank you all!


Solution

  • I have solved my problem. Issue was Windows line ending of ssmtp.conf file.

    It explains why username was not correct and why Debug flag and UseSTARTTLS flag changes were not respected.

    Many thanks to @telcoM for a way to debug server flow.