SMTP Authを使った外部のSMTPサーバーへのリレー方法

自宅サーバーからメールを送信する際に、直接メールを送信するのではなく、ISPが提供しているSMTPサーバーを利用する。
通常は固定グローバルIPでは無いため、SPAM扱いされ易いが、正規のSMTPサーバー経由で送信するので素性の知れたメールになるので少しはSPAM扱いされにくくなる。OSは、Ubuntu 10.04サーバーを使用。


1./etc/postfix/main.cf を以下のように編集。

#relayhost = [プロバイダから指定されているSMTPサーバーのIPまたはホスト名]
relayhost = [smtp.comcast.net]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=


2. /etc/postfix/sasl_passwd を以下のように作成

smtp.comcast.net ユーザID:パスワード

Comcastの場合は、@comcast.netの前の部分。

念のため以下のようにしておく。

$ sudo chown root:root /etc/postfix/sasl_passwd
$ sudo chmod 600 /etc/postfix/sasl_passwd

3. postmapコマンドを実行

$ sudo postmap hash:/etc/postfix/sasl_passwd

4. Postfix のリロード

$ sudo /etc/init.d/postfix reload