LoginSignup
0
2

More than 5 years have passed since last update.

pythonで立てたダミーSMTP サーバーにmailxでメールを送る。

Last updated at Posted at 2017-02-14

pythonを使ったダミーのSMTPサーバは以下のコマンドで簡単に起動できます。

python -m smtpd -n -c DebuggingServer localhost:8025

しかし、このサーバに対しmailxでメールを送ろうとしたところ地味に手こずったので備忘録代わりに手順を書いておきます。
mailxはsendmailまたはpostfixなどのMTAにメールを送るので
sendmailまたはpostfixのリレーサーバに上記のダミーSMTPサーバを指定すると良いです。
私の環境ではpostfixが動いていたので
/etc/postfix/main.cfに以下の設定を追加しました。

relayhost = [127.0.0.1]:8025

そしてpostfixを再起動します。

sudo systemctl restart postfix.service

これで送信

echo "test" | mail -v -s "test" hoge@example.com

ダミーのSMTPサーバにメールが届くはずです。

※localhostにメールを送った場合、設定によりますが
自分のメールボックスにそのまま入ってしまうため
ダミーのSMTPサーバに届きません。ご注意下さい。

※CentOS7環境で試しています。

0
2
2

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
0
2