※ドメインを「hogehoge.com」とする
※RELAYを許可するネットワークは「192.168.11.0/24」「111.222.33.44」とする
Sendmailをひとまず止めておく
1 |
$ sudo /etc/init.d/sendmail stop |
sendmail-cfをインストール(既にインストール済みならスルー)
1 |
$ sudo yum install sendmail-cf |
こんな感じで設定
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 27 28 29 30 31 32 33 34 35 36 37 38 39 |
$ cd /etc/mail $ sudo cp ./access ./access.org $ sudo cp ./sendmail.cf ./sendmail.cf.org $ sudo cp ./sendmail.mc ./sendmail.mc.org $ sudo vi ./sendmail.mc ----- 変更>> DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl ↓ DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl ↓ DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl dnl MASQUERADE_AS(`mydomain.com')dnl ↓ MASQUERADE_AS(`hogehoge.com')dnl dnl FEATURE(masquerade_envelope)dnl ↓ FEATURE(masquerade_envelope)dnl << ----- $ sudo vi ./access ----- 追加>> 192.168.11 RELAY 111.222.33.44 RELAY << ----- $ sudo vi ./local-host-names ----- 追加>> hogehoge.com << ----- |
.mcから.cfを生成
1 |
$ sudo m4 /usr/share/sendmail-cf/m4/cf.m4 ./sendmail.mc > ./sendmail.cf |
accessファイルをハッシュ化
1 |
$ sudo makemap hash ./access.db < ./access |
次はdovecot。
まずインストール
1 |
$ sudo yum install dovecot |
続いて設定
1 2 3 4 5 6 7 |
$ sudo cp /etc/dovecot.conf /etc/dovecot.conf.org $ sudo vi /etc/dovecot.conf ----- 変更>> protocols = pop3 << ----- |
最後にpop-before-smtp。これはyumでは入らなさそう。
1 2 3 4 5 6 7 8 |
$ cd /usr/src $ sudo wget http://sourceforge.net/projects/popbsmtp/files/Source%20tar/1.42/pop-before-smtp-1.42.tar.gz/download $ sudo tar xvfz ./pop-before-smtp-1.42.tar.gz $ sudo cd ./pop-before-smtp-1.42 $ sudo cp ./pop-before-smtp.init /etc/rc.d/init.d/pop-before-smtp $ sudo cp ./pop-before-smtp /usr/sbin/ $ sudo cp ./pop-before-smtp-conf.pl /etc/ $ sudo cp ./contrib/popauth.m4 /usr/share/sendmail-cf/hack |
perlのモジュールが足りていない
1 2 3 4 5 6 7 8 9 10 11 |
$ sudo perl -MCPAN -e shell 国とFTPサーバの選択だけ選んであとはEnterのみ Select your continent (or several nearby continents) [] 2 Select your country (or several nearby countries) [] 6 cpan> install Time::HiRes cpan> install File::Tail cpan> install Date::Parse cpan> install Net::Netmask cpan> install BerkeleyDB cpan> exit |
設定
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 27 28 |
$ sudo vi /etc/pop-before-smtp-conf.pl ----- 変更>> $logto = '/var/log/pop-before-smtp'; $grace = 10*60; $file_tail{'name'} = '/var/log/maillog'; =cut #------------------------- Sendmail SMTP -------------------------START- ↓ #------------------------- Sendmail SMTP -------------------------START- =cut #------------------------- Sendmail SMTP ---------------------------END- ↓ #------------------------- Sendmail SMTP ---------------------------END- # For Dovecot POP3/IMAP when using syslog. #$pat = '^[LOGTIME] \S+ (?:dovecot: )?(?:imap|pop3)-login: ' . # 'Login: .*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]'; #$out_pat = '^[LOGTIME] \S+ (?:dovecot: )?(?:imap|pop3)-login: ' . # 'Disconnected.*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]'; ↓ # For Dovecot POP3/IMAP when using syslog. $pat = '^[LOGTIME] \S+ (?:dovecot: )?(?:imap|pop3)-login: ' . 'Login: .*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]'; #$out_pat = '^[LOGTIME] \S+ (?:dovecot: )?(?:imap|pop3)-login: ' . # 'Disconnected.*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]'; << ----- |
sendmail.mcに追加
1 2 3 4 5 6 7 8 9 |
$ sudo vi /etc/mail/sendmail.mc ----- 追加>> define(`POP_B4_SMTP_TAG', `')dnl HACK(popauth) << ----- $ sudo m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf |
起動
1 2 3 4 5 6 7 |
$ sudo /etc/init.d/sendmail start $ sudo /etc/init.d/dovecot start $ sudo /sbin/chkconfig dovecot on $ sudo /etc/init.d/pop-before-smtp start $ sudo /sbin/chkconfig --add pop-before-smtp |
◎参考
CentOS の設定