exim4 x gmailのスマートホストによるメール送信(メール送信はこれが便利かな)

sendmailを使いたいが信頼度の高いsmtp経由させてメールを送信させたい。exim4のスマートホストなら簡単に設定ができます。

http://highfrontier.ldblog.jp/tag/GMail
からほとんど引用させてもらっています。私も試してしっかりと動いたのでメモ+自分用保存で掲載させて頂きました。

# dpkg-reconfigure exim4-config
1. General type of mail configuration: スマートホストでメール送信; SMTP または fetchmail で受信する
2. System mail name: localhost
3. IP-addresses to listen on for incoming SMTP connections: 127.0.0.1
4. Other destinations for which mail is accepted: localhost
5. Machines to relay mail for:
6. IP address or host name of the outgoing smarthost: smtp.gmail.com:587
7. Hide local mail name in outgoing mail? <No>
8. DNS クエリの数を最小限に留めますか (ダイヤルオンデマンド)? <No>
9. ローカルメールの配送方式: /var/mail/ 内の mbox 形式
10. Split configuration into small files? <Yes>

の順番でうまくいきます。下記のスクリーンショットを貼っておきます。













設定が終わると

# vi /etc/exim4/passwd.client
gmail-smtp.l.google.com:youraccount@gmail.com:yourpassword
*.google.com:yourassount@gmail.com:yourpassword
smtp.gmail.com:yourassount@gmail.com:yourpassword

の内容です。削ってもいい部分ありますが。

ローカルのユーザとgmailを結びつけるには下記の設定を行います。

# vim /etc/exim4/email-addresses

内容は

yourasount@localhost: yoursccount@gmail.com


最後にexim4を再起動します。

# /etc/init.d/exim4 restart

Google Apps独自ドメインでもアカウント名の部分(上記ではyouraccount@gmail.comの部分)を
自分のドメインにすることで対応が可能です。