今回はメール関連のお話。実はお試し期間中はメールが送信できない。クレジット支払いを選択してる方は「クレジットカードによるお支払いについてのお知らせ」というメールが届くまでメールが送信できないと思われる。
■sendmail
昔っからあるメール送信サーバ。さくらのVPSにデフォルトでインストールされている。
設定ツールのインストール
yum install sendmail-cf
設定ツールの編集
vi /etc/mail/sendmail.mc
接続を受けるアドレスを編集
以下の部分から
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
Addr=127.0.0.1の部分を削除し
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
外部からのメールを送受信できるようにする。
ドメインの変更
以下の部分を
LOCAL_DOMAIN(`localhost.localdomain')dnl
以下のようにホスト名に変更する。
LOCAL_DOMAIN(`www1234u.sakura.ne.jp')dnl
ホスト名の追加
以下の部分を
vi /etc/mail/local-host-names
以下のようにホスト名を追記する。
www1234u.sakura.ne.jp
設定変更を反映させた後、サーバを再起動する。
cd /etc/mail make /sbin/service sendmail restart
■postfix
postfixをインストールしたい場合もあるかもしれない。通常はsendmailかpostfixのどちらかがあれば十分だ。
yum install postfix
設定
設定ファイルを編集する。
vi /etc/postfix/main.cf
ホスト名の設定
以下の部分に
#myhostname = host.domain.tld #myhostname = virtual.domain.tld
以下のようにメールサーバ名を追記する。
#myhostname = host.domain.tld #myhostname = virtual.domain.tld myhostname = www1234u.sakura.ne.jp
ドメイン名の設定
以下の部分に
#mydomain = domain.tld
以下のようにドメインを追記する。
#mydomain = domain.tld mydomain = www1234u.sakura.ne.jp
送信アドレスにおける@マーク以降の部分の設定
以下の部分に
#myorigin = $mydomain
以下のように送信者の@マーク以降の部分を記述してあげる。
#myorigin = $mydomain myorigin = $mydomain
待ち受けるべき全てのネットワークインターフェースの設定
実は初期設定ではインターネットからのメールが受信できないので、以下の部分を
inet_interface = localhost
以下のように変更する。
inet_interface = all
自ホスト宛てとして保存すべきメールアドレスの @以降を設定
また、以下の部分を
mydestination = $myhostname, localhost.$mydomain, localhost
以下のように変更する。
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
ホームディレクトリの設定
また、以下の部分を
#home_mailbox = Maildir/
以下のように変更しメールボックスのディレクトリを設定する。
#home_mailbox = Maildir/ home_mailbox = Maildir/
サーバソフト名の設定
また、以下の部分を
#smtpd_banner = $myhostname ESMTP $mail_name #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
以下のように変更しメールサーバーソフト名を隠す。
#smtpd_banner = $myhostname ESMTP $mail_name #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) smtpd_banner = $myhostname ESMTP unknown
サーバソフト名の設定
以下をファイルの最終行に追記する。
# SMTP-Auth configuration smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination # limit message_size_limit = 10485760
認証デーモンを起動
システムアカウント情報を認証情報として利用したいので、以下のコマンドで認証デーモンを起動する。
/etc/rc.d/init.d/saslauthd start chkconfig saslauthd on chkconfig --list saslauthd
メールボックスの設定
mkdir -p /etc/skel/Maildir/{new,cur,tmp} chmod -R 700 /etc/skel/Maildir/
sendmailの停止
/etc/rc.d/init.d/sendmail stop chkconfig sendmail off
メールサーバの切替
alternatives --config mta
postfixの起動
/etc/rc.d/init.d/postfix start chkconfig postfix on
■dovecot
メールの送信はできるようになったはずだが、受信が今のままではできないはずだ。以下のコマンドでdovecotをインストールする。
yum install dovecot
設定
以下のコマンドで設定ファイルを編集する。
vi /etc/dovecot.conf
プロトコルの設定
以下のコメントアウト部分を
#protocols = imap imaps pop3 pop3s
以下のようにコメントを外してあげる。
protocols = imap imaps pop3 pop3s
メールボックスディレクトリの設定
以下の部分に
#mail_location =
以下のような追記を加える。
#mail_location = mail_location = maildir:~/Maildir
起動
/etc/rc.d/init.d/dovecot start chkconfig dovecot on
info宛のメールがrootに転送される
以下のコマンドを実行し
vim /etc/aliases
以下の部分をコメントアウトして
info: postmaster
以下のようにする。
#info: postmaster
ピンバック: Tweets that mention さくらのVPSをもう少しセットアップしてみる - @blog.justoneplanet.info -- Topsy.com
ピンバック: さくらVPSでメールの設定をサボったらgmailに届かなかったので設定した | のぶろぐ
ピンバック: さくらVPSのお試し期間 » trial-run.info/blog
こんにちわ、さくらのVPSでメールを送受信する方法を検索して飛んで来ました。
postfixやdovecotの導入の仕方がわかりやすく書かれていて、とても助かりました。
ありがとうございました。
ところで真ん中の方にある
■認証デーモンの起動
/etc/rc.d/init.d/saslauthd startchof
は
/etc/rc.d/init.d/saslauthd start
ですよね、ちょっとだけ気になったので^^;
ご指摘ありがとうございます!!!
修正致します〜
ピンバック: Redmineの構築 | Tanaka blog
ピンバック: さくらのVPS 512プランから1Gプランに乗り換え始めます!参考記事準備編 – [Mu]ムジログ
vi /etc/dovecot.conf
とすると新規で作成されてしまいます。
インストールも起動もうまくいくのですが
なぜでしょうか?
dovecotのバージョンが違ってるからだと思います。
/etc/dovecot/
配下にファイルが分かれてると思います。