LoginSignup
7
6

More than 5 years have passed since last update.

Raspberry Pi 2(略してパイ2)からメール送信できるようにする

Posted at

概要

Raspberry Pi 2からメール送信できるようPostfixを導入します。
またシェルからメール送信できるようmailコマンドを実行できるようにします。

Postfixの導入

postfixをインストールします。

$ sudo apt-get install postfix

pi003.PNG

pi004.PNG

pi005.PNG

postfixの初期設定を行います。
現状ではIPv6が有効になっているとトラブルが多いためIPv4のみに設定します。
経験上SPFレコード関連なのですがIPv6のSPF設定は情報がまだ少ない気がするので。

$ sudo vi /etc/postfix/main.cf
    inet_protocols = ipv4

最後にpostfixを再起動して設定を反映します。
bash
$ sudo service postfix restart

メール送信テスト

mailコマンドが使えるようにmailutilsパッケージをインストールします。

$ sudo apt-get install mailutils

mailコマンドでメール送信を行い、宛先にメールが届けば完了です。
届かない場合は、/var/log/mail.log を確認し対処します。

$ echo "This is test mail." | mail -s "test" root
7
6
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
7
6