4
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dockerコンテナからメール送信

Posted at

参考

自前でSMTPサーバーを準備すること。

サンプル

Dockerfile
FROM php:7.2-rc-apache

RUN apt update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ssmtp

RUN echo 'sendmail_path = "/usr/sbin/ssmtp -t"' > /usr/local/etc/php/conf.d/mail.ini

RUN echo "FromLineOverride=YES" >> /etc/ssmtp/ssmtp.conf \
 && echo "Mailhub=SMTPサーバー:25" >> /etc/ssmtp/ssmtp.conf
run.sh
docker run -it --rm \
 -v $(pwd)/html/:/var/www/html/ \
 -p 8080:80 \
 1ce5db3c0fdb
html/a.php
<?php
mail('to@example.jp','subject','body');

http://localhost:8080/a.php にアクセスしてメールがto@example.jpに届くことを確認。

4
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?