メールサーバ構築
mxレコード確認
$ dig psychobil.ly mx +short
10 mail.psychobil.ly.
/etc/postfix/main.cf編集
76a77
> myhostname = mail.psychobil.ly
83a85
> mydomain = psychobil.ly
99c101< #myorigin = $mydomain
- -
> myorigin = $mydomain
113c115< #inet_interfaces = all
- -
> inet_interfaces = all
116c118< inet_interfaces = localhost
- -
> #inet_interfaces = localhost
164,165c166,167< mydestination = $myhostname, localhost.$mydomain, localhost< #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
- -
> #mydestination = $myhostname, localhost.$mydomain, localhost
> mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
419c421< #home_mailbox = Maildir/
- -
> home_mailbox = Maildir/
570a573
> smtpd_banner = $myhostname ESMTP unknown
676a680,688
>
> smtpd_sasl_auth_enable = yes
> smtpd_sasl_local_domain = $myhostname
> smtpd_recipient_restrictions =
> permit_mynetworks
> permit_sasl_authenticated
> reject_unauth_destination
>
> message_size_limit = 10485760
$ sudo /etc/rc.d/init.d/saslauthd start
$ sudo chkconfig saslauthd on
$ diff /etc/sasl2/smtpd.conf.org /etc/sasl2/smtpd.conf
1c1< pwcheck_method: saslauthd
- -
> pwcheck_method: auxprop
Maildir形式メールボックス作成
sendmail停止
$ sudo mkdir -p /etc/skel/Maildir/{new,cur,tmp}
$ sudo chmod -R 700 /etc/skel/Maildirメールサーバー切替え
$ sudo alternatives --config mtaThere are 2 programs which provide 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2postfix起動
$ sudo /etc/init.d/postfix start
$ sudo chkconfig postfix on
$ sudo /etc/init.d/postfix start
ポート25(SMTP),110(POP3),143(IMAP)を開ける
awsのコンソールのsecurity groupsから設定する
メールユーザ追加
$ sudo useradd username
SMTP-Auth用ユーザ名、パスワードとシステムのユーザ名、パスワードを別々にする場合
$ sudo passwd username
echo password | sudo saslpasswd2 -p -u psychobil.ly -c ec2-user
$ sudo chgrp postfix /etc/sasldb2
postfix起動
$ sudo /etc/init.d/sendmail stop
$ sudo chkconfig sendmail off
dovecot(POP)インストール
$ diff /etc/dovecot/dovecot.conf.org /etc/dovecot/dovecot.conf
20a21
> protocols = imap pop3
82a84,85
> mail_location = maildir:~/Maildir
> disable_plaintext_auth = no$ diff /etc/dovecot/conf.d/10-mail.conf.org /etc/dovecot/conf.d/10-mail.conf
30a31
> mail_location = maildir:~/Maildir$ sudo /etc/init.d/dovecot start
$ sudo chkconfig dovecot onメールディレクトリ作成
$ mkdir /home/ec2-user/Maildir環境変数変更
$ echo $MAIL
/var/spool/mail/ec2-user
$ export MAIL=/home/ec2-user/Maildir
参考
http://www.criterion.sc/sub_notes/postfix.html
http://fedorasrv.com/postfix.shtml