2011 10月 16

自宅サーバからインターネットにメールを出す場合、プロバイダ側で制限されている場合がある。
これを、OP25B(Outbound Port 25 Blocking)対策という。
この場合、プロバイダ側でメール中継サーバを用意してある場合がある。
自宅サーバからメールを出す場合は、このメール中継サーバを使用してメールを送信する。
メール中継サーバの有無は、各プロバイダのホームページを見て確認して欲しい。
今回、SMTPサーバはsendmail、サーバOSは、CentOS 5.3 である。
 
また、今回参考にしたのは、『OP25B(Outbound Port 25 Blocking)対策』である。
 



 

Sendmailの設定

プロバイダのメール中継サーバと使用するポート番号を調べたら、まずsendmail.cfを作成しなおす。
 

# yum install sendmail-cf
# cd /etc/mail/
# mv sendmail.mc sendmail.mc.org
# vi sendmail.mc

<省略>

 define(`SMART_HOST', `esmtp:[プロバイダのメール中継サーバ名]')dnl
 define(`ESMTP_MAILER_ARGS',`TCP $h ポート番号')
 FEATURE(authinfo, DATABASE_MAP_TYPE` -o 'MAIL_SETTINGS_DIR`authinfo')

<省略>

# m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

 

プロバイダのメール中継サーバの認証方式の設定

telnet で、プロバイダのメール中継サーバ名とポート番号を指定してアクセスすることで、プロバイダのメール中継サーバの認証方式を調べる事が出来る。
その認証方式を /etc/mail/authinfo.db に設定し、sendmailを再起動することで、プロバイダのメール中継サーバにアクセスする事が出来るようになる。
 

# telnet プロバイダのメール中継サーバ名 ポート番号

Trying xxx.xxx.xxx.xxx...
Connected to プロバイダのメール中継サーバ名 (xxx.xxx.xxx.xxx).
Escape character is '^]'.
220 プロバイダのメール中継サーバ名 SMTP-Gateway Version 2.13 at Tue, 11 Oct 2011 00:00:09 +0900 (JST)
ehlo localhost
250-プロバイダのメール中継サーバ名 Hello localhost [xxx.xxx.xxx.xxx], pleased to meet you
250-AUTH CRAM-MD5 LOGIN PLAIN   ←認証方式
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE 104857600
250-DSN
250-DELIVERBY
250 HELP
quit
221 2.0.0 プロバイダのメール中継サーバ名 closing connection
Connection closed by foreign host.

# echo AuthInfo:プロバイダのメール中継サーバ名 \"U:ユーザ名\" \"P:パスワード\" \"M:認証方式\" > /etc/mail/authinfo

# chmod 640 /etc/mail/authinfo
# makemap hash /etc/mail/authinfo.db < /etc/mail/authinfo
# chgrp smmsp /etc/mail/authinfo.db
# service sendmail restart

 
上記を例に取れば、echo AuthInfo:~ の\”M:認証方式\”の部分は、\”M:CRAM-MD5 LOGIN PLAIN\”となる。
 

 


Categories: sendmail


Leave a Reply