Lunux

SSMTPのインストールと設定

CentOSをインストールしたが、別にあるメールサーバーに対して
logwatchのメールを送信したいのでその際の設定をメモ。
デフォルトのsendmailを使用した設定だとなぜかうまくいかなかった・・・
今回は送信専用のssmtpというソフトを利用する。

1.追加モジュールのインストール
yum install openssl-devel

2.sssmtpダウンロード
ダウンロード元http://packages.debian.org/source/sid/ssmtp

最新版はダメっぽいので昔のを使用。
wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/s/ssmtp/ssmtp_2.62-3.diff.gz

3.Sendmailの無効化
service sendmail stop
chkconfig sendmail off
yum remove sendmail

4.ソースファイルの展開とコンパイル
gunzip ssmtp_2.62-3.diff.gz
tar zxvf ssmtp_2.62.orig.tar.gz
cd ssmtp
patch -p1 < ../ssmtp_2.62-3.diff
./configure –enable-ssl  ※SSL通信する必要がある場合はつけるっぽい。
make
make install
以下、入力待ちとなる。

Mail name [サーバー名]: Enterでデフォルト値を設定
Please enter the SMTP port number [25]: Enterでデフォルト値を設定

5.ssmtpの設定
vi /usr/local/etc/ssmtp/ssmtp.conf

root=hoge@hiroroom.net  ※送信先
mailhub=mail.hiroroom.net ※使用するメールサーバー

6.設定ファイル(revaliases)の設定
vi /usr/local/etc/ssmtp/revaliases

root:hoge@hiroroom.net:mail.hiroroom.net
※送信先         ※使用するメールサーバー

7.シンボリックリンクを張り替え
ln -s /usr/local/sbin/ssmtp /usr/sbin/sendmail

8.テスト
logwatch

ちゃんとメールが送信されてればOK