1
2

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 3 years have passed since last update.

送信メールサーバメモ [Postfix × SASL × Gmail]

Last updated at Posted at 2021-02-04

概要

  • 通知用の送信メールサーバがほしい
  • セキュリティはある程度担保したい
  • 設定に時間かけたくない
  • SMTPはGmailに任せる
  • セキュリティはSASLとGmailのセキュリティ機能に任せる

詳細

  • 設定に必要なものをインストール
sudo apt install postfix
sudo apt install sasl2-bin
  • postfix設定
sudo vi /etc/postfix/main.cf
/etc/postfix/main.cf
:
#====== Append Gmail Config =====
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_tls_CApath = /etc/pki/tls/certs/ca-bundle.crt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
#================================
:

  • sasl設定(認証情報設定)
sudo vi /etc/postfix/sasl_passwd
[smtp.gmail.com]:587  mailhost-username@xxx.com:password
  • 認証情報ハッシュ&有効化
$ sudo postmap hash:/etc/postfix/sasl_passwd
  • メールサーバプロセス起動
$ sudo systemctl restart postfix
  • Gmail側設定
  • 外部アプリ使用許可およびセキュリティレベル変更

image.png

image.png

  • mailコマンドインストール
$ sudo apt install mailutils
  • 送信テスト
$ echo "test mail recieve" | mail -s "mail test via Gmail" user@geeplus.jp
  • 受信確認

image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?