sSMTP で Gmail からメールを送る

Debian を入れて自宅サーバとして使っていた Thinkpad T42 が Fan Error で起動しなくなり、パーツ交換するのも面倒だし中古の X40 2371-7VJ を GENO で 3 万円弱で買いました。サイトが多少重いときがあるみたいですが、安いですし届いたマシンもめちゃきれいでした。

というわけで、今回は Ubuntu 入れてみようと思い CD ドライブもないので UNetBootin で Ubuntu 8.10 を選んでインストール。Windows のパーティションもガツンと消して無事完了。

パッケージの管理の仕方も Debian とほとんど同じみたいだしセットアップで困ることはあまりなかったのですが、WordPress の WP-DB-Backup でバックアップを定期的にメールで送ろうとすると PHPMailer が使う /usr/sbin/sendmail を用意してあげないといけません。Sendmail とか Postfix とか別にメールサーバ立てたいわけじゃなくて送信だけしたいんスよ、というわけで sSMTP。

$ sudo apt-get install ssmtp

でインストールして、Gmail のアカウントからメールを送れるよう /etc/ssmtp/ssmtp.conf を編集します。23 行目の AuthUser と 24 行目の AuthPass は自分のアカウントのものにすれば良いです。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
 
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com
 
# Where will the mail seem to come from?
rewriteDomain=gmail.com
 
# The full hostname
hostname=gmail.com
 
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
 
AuthUser=your_id@gmail.com
AuthPass=your_password
useSTARTTLS=YES
# DEBUG=YES

で、テスト。最終行の test を入力して改行した後は Ctrl-D で抜けます。From と To は自分のアドレスを指定しましょう。

$ sendmail -t
From: your_id@gmail.com
To: your_id@gmail.com
Subject: test
 
test

これで Gmail に自分からメールが届くはずです。めでたい。


About this entry