web-dev-qa-db-ja.com

phpとsendmailを使用してDockerコンテナのテストに関するメールを送信する

私はubuntu16.04にいます。 php5.6とApache2.4を実行する(テスト用)docker(docker-compose)コンテナーがあります。

本番プラットフォーム(Dockerなし)では、メールはsendmailで送信されます。

Dockerコンテナでテストメールを送信する方法(sendmailを使用)?

返信ありがとうございます。

4
ratm

できます。

Dockerfileの場合:

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

RUN apt-get install -q -y ssmtp mailutils

# root is the person who gets all mail for userids < 1000
RUN echo "[email protected]" >> /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 "[email protected]" >> /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コンテナ内のテスト用:

echo "Un message de test" | mail -s "sujet de test" [email protected]

私はこの2つのドキュメントの助けを借りて成功します:

15
ratm