Send email on testing docker container with php and sendmail

笑着哭i 提交于 2019-12-03 13:59:10

问题


I'm on ubuntu 16.04. I have a (testing) docker (docker-compose) container running php 5.6 and apache 2.4.

With production plateform (without docker) the mail is send with sendmail.

How to send test email on docker container (with sendmail) ?

Thanks in advance for responses.


回答1:


It works.

In Dockerfile :

# sendmail config
############################################

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


# 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 "Un message de test" | mail -s "sujet de test" mailSendingAdresse@email.com

I succeed with the help of this two documents :

  • https://unix.stackexchange.com/questions/36982/can-i-set-up-system-mail-to-use-an-external-smtp-server
  • https://github.com/cmaessen/docker-php-sendmail/blob/master/Dockerfile


来源:https://stackoverflow.com/questions/47247952/send-email-on-testing-docker-container-with-php-and-sendmail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!