使用php和sendmail在测试docker容器上发送电子邮件 [英] Send email on testing docker container with php and sendmail

查看:337
本文介绍了使用php和sendmail在测试docker容器上发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 16.04。我有一个运行php 5.6和apache 2.4的(测试)docker(docker-compose)容器。

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

在生产平台(没有docker)上,该邮件是通过sendmail发送的。

On the production platform (without docker) the mail is sent with sendmail.

如何在docker容器上(带有sendmail)发送测试电子邮件?

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

感谢您的回复。

推荐答案

它可行。

在Dockerfile中:

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

用于内部测试php sendmail容器:

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

这篇关于使用php和sendmail在测试docker容器上发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆