10
11

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.

Postfix Tips

Last updated at Posted at 2014-05-02

ちょっとした設定とか

Relay する

% sudo vi /etc/postfix/main.cf
 
relayhost = [smtp.my.server]
 
% cd /etc/postfix
% sudo postmap transport

Postfix は /etc/hosts を参照しないので、内部 DNS がない場合は IP を指定する

Relay 先で受け入れる設定を施しておく必要有り。Postfix なら以下がポイント

  • mynetworks を定義しておく
  • mydestination に $mydomain を入れる
  • inet_interfaces = all にしておく(CentOS 6.x だとデフォルトは local のみ LISTEN っぽい)

smtp.gmail.com と連携する

MTA が Postfix になってるか確認しておく

% alternatives --config mta

smtp.gmail.com の Root CA をダウンロードして配置

% get https://www.thawte.com/roots/thawte_Premium_Server_CA.pem
% sudo mv thawte_Premium_Server_CA.pem /etc/pki/tls/certs/

設定追加

% sudo vi  /etc/postfix/main.cf
 
myhostname = // FQDN
mydomain = // DOMAIN_NAME
myorigin = $mydomain
 
relayhost = [smtp.gmail.com]:587
 
 
smtp_use_tls = yes
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
 
 
smtp_tls_CApath = /etc/pki/tls/certs/thawte_Premium_Server_CA.pem

/etc/postfix/sasl_passwdを作成してハッシュ化

% cat /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 username@gmail.com:password
 
% sudo chown root:root /etc/postfix/sasl_passwd
% sudo chmod 600 /etc/postfix/sasl_passwd
 
% postmap /etc/postfix/sasl_passwd

起動

% sudo service postfix start

mail コマンドでテストとか。mailx パッケージにある。

SASL authentication failed; cannot authenticate ...

SASL authentication failed; cannot authenticate to server smtp.gmail.com[XXX.XXX.XXX.XXX]: no mechanism available

パッケージを確認

% sudo yum install cyrus-sasl-plain

From 書き換え

リレーに使う Gmail の「設定」→「アカウント」から「メールアドレスを追加」で設定しておいたアドレスのみ上書きで送信可能

10
11
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
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?