Tip
Alternatively one could use
msmtp
SSMTP to prosty MTA, ktory na systemie domowym w zupelnosci wystarczy jesli chcemy przekierowac emaile poprzez zewnetrzny serer SMTP np GMAIL.
/etc/ssmtp/ssmtp.conf
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.host.com:587
# Where will the mail seem to come from?
rewriteDomain=mydomain.net
# The full hostname
hostname=mydomain.net
UseTLS=yes
UseSTARTTLS=yes
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES
AuthUser=myuser
AuthPass=mypassword
in Docker
RUN apt-get install -q -y ssmtp mailutils
# root is the person who gets all mail for userids < 1000
RUN echo "root=yourAdmin@email.com" >> /etc/ssmtp/ssmtp.conf
# Here is the gmail configuration (or change it to your private smtp server)
RUN echo "mailhub=smtp.gmail.com:587" >> /etc/ssmtp/ssmtp.conf
RUN echo "AuthUser=your@gmail.com" >> /etc/ssmtp/ssmtp.conf
RUN echo "AuthPass=yourGmailPass" >> /etc/ssmtp/ssmtp.conf
RUN echo "UseTLS=YES" >> /etc/ssmtp/ssmtp.conf
RUN echo "UseSTARTTLS=YES" >> /etc/ssmtp/ssmtp.conf
# For PHP set up php sendmail config
RUN echo "sendmail_path=sendmail -i -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
For testing inside php sendmail container :
echo "Test message" | mail -s "Test subject" who@email.com