LoginSignup
1
0

More than 5 years have passed since last update.

Proxmox VEでGmailを送る

Last updated at Posted at 2016-05-10

はじめに

Proxmox VEでGmailを送ろうとしたのですが、gmail notifications over ssl 587 portの通りではSASLで引っかかったので、うまくいった手順を書き残します。

postfix、libsasl2-modulesおよびsasl2-binをインストール

apt-get install -y postfix libsasl2-modules sasl2-bin

/etc/postfix/main.cfを書き換え

relayhost = [smtp.gmail.com]:587 #フォーラムでは何も書かれていませんが、こうしています(消す検証はしていません)。

/etc/postfix/main.cfに追加

smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relayhost.hash

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_auth.hash
smtp_sasl_security_options = noanonymous #フォーラムではnoplaintext, noanonymousですが、SASLで引っかかりました。

smtp_use_tls = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

/etc/postfix/sasl_auth.hashを作成

user@gmail.com user@gmail.com:password

#default
[smtp.gmail.com]:587 user@gmail.com:password #フォーラムではこの行はありませんが、こうしています(消す検証はしていません)。

/etc/postfix/sender_relayhost.hashを作成

user@gmail.com [smtp.gmail.com]:587

パーミッション設定・設定反映

postmap /etc/postfix/sasl_auth.hash
postmap /etc/postfix/sender_relayhost.hash

chmod u=rw,g=,o= /etc/postfix/sasl_auth.hash
chmod u=rw,g=,o= /etc/postfix/sasl_auth.hash.db

postfix reload

テスト

date | mail -s test user@gmail.com

ログの確認

tail -n 10 /var/log/mail.log

その他

Proxmox VEのインストール時にメールアドレスを要求されますが、それはPAMでrootユーザーのメールアドレスとして設定されています。そのためrootユーザーにメールを送ればそのメールアドレスに送られるはずです。

date | mail -s test root@hostname.local

からくりとしては/root/.forwardに/usr/bin/pvemailforwardを読むように書かれており、pvemailforwardでPAMを読みにいっているようです。

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