sendmailでsubmissionポートを使用したSMTP-Authの設定

2008 / 06 / 15 ( Sun )
この記事をはてなブックマークに登録する この記事をYahoo!ブックマークに登録する この記事をlivedoorクリップに登録する
sendmailsubmissionポートを使用したSMTP-Authを行う場合、sendmail.mcのDAEMON_OPTIONSに587番ポートを使用する設定を以下のように書けばOKです。
DAEMON_OPTIONS(`Port=587, Name=MSA, M=Ea')dnl

でも、実はこれだけだと不十分(と思う)。

なぜか?
25番ポートは25番ポートらしい仕事を、
587番ポートは587番ポートらしい仕事をやってほしい
と思うからです。
つまり、
・25番ポートはSMTP専用とする。
・25番ポートはSMTP-Authにしても送信できない。
・587番ポートはSMTP-Auth専用とする。
・587番ポートは通常のSMTP通信は行えない。
という動きにしたいからです。

実現するには、sendmail.mcに以下のように書きます。
FEATURE(`no_default_msa')dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA, M=A')dnl
DAEMON_OPTIONS(`Port=587, Name=MSA, M=Ea')dnl

M=の後に続くオプションは、
A…認証を無効にする。
a…認証を必要とする。
E…ETRNコマンドの使用を禁止する。
ということを指定しています。

ETRNとはTURNコマンドのセキュリティ強化版で、通常とは逆向きにメールの送信を行う仕組みです。587番ポートはメールクライアントからメールを送信する為の専用ポートなので、逆向きにメールの送信を行うようなことはありえません。ので、オプションEを指定しています。

また、DAEMON_OPTIONSの前に、FEATURE(`no_default_msa')を書いています。
これは、デフォルトで設定されているMSA(Message Submission Agent)を一旦無効にし、その後改めてMSAの設定を行う為です。

この設定を行った場合の、telnetコマンドを使用した動作を確認しました。

図のような環境でメールクライアント端末から、メールサーバーmta.example.comを使用して、hoge@example.com宛てにメールを送信する場合の操作ログは以下のようになります。

SMTP送信テスト

▼25番ポートを使用してメール送信。SMTP-Auth未使用の場合。
「リレー拒否。認証使ってよ。(Relaying denied. Proper authentication required.)」と怒られ送信できません。
$ telnet mta.example.com 25
Trying 172.16.1.25...
Connected to mta.example.com.
Escape character is '^]'.
220 mta.example.com ESMTP Sendmail 8.13.8/8.13.8; Sat, 14 Jun 2008 23:23:33 +0900 (JST)
helo mail
250 mta.example.com Hello fw.foobar.net [192.168.100.100], pleased to meet you
mail from: hoge@example.com
250 2.1.0 hoge@example.com... Sender ok
rcpt to: hoge@example.co.jp
550 5.7.1 hoge@example.co.jp... Relaying denied. Proper authentication required.
quit
221 2.0.0 mta.example.com closing connection
Connection closed by foreign host.
$


▼25番ポートを使用してメール送信。SMTP-Authの使用を試みた場合。
「認証機能は使えないよ。(Auth not available)」と怒られ送信できません。
$ telnet mta.example.com 25
Trying 172.16.1.25...
Connected to mta.example.com.
Escape character is '^]'.
220 mta.example.com ESMTP Sendmail 8.13.8/8.13.8; Sat, 14 Jun 2008 23:25:22 +0900 (JST)
ehlo mail
250-mta.example.com Hello fw.foobar.net [192.168.100.100], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
auth plain c29xxxxxxxxxxxxxxxxxxxxxxxxxxxx0
503 5.3.3 AUTH not available
quit
221 2.0.0 mta.example.com closing connection
Connection closed by foreign host.
$


▼587番ポートを使用してメール送信。SMTP-Auth未使用の場合。
「認証が必要だよ。(Authentication required)」と怒られ送信できません。
$ telnet mta.example.com 587
Trying 172.16.1.25...
Connected to mta.example.com.
Escape character is '^]'.
220 mta.example.com ESMTP Sendmail 8.13.8/8.13.8; Sat, 14 Jun 2008 23:26:53 +0900 (JST)
helo mail
250 mta.example.com Hello fw.foobar.net [192.168.100.100], pleased to meet you
mail from: hoge@example.com
530 5.7.0 Authentication required
quit
221 2.0.0 mta.example.com closing connection
Connection closed by foreign host.
$


▼587番ポートを使用してメール送信。SMTP-Authを使用した場合。
送信できました。(^^)v
$ telnet mta.example.com 587
Trying 172.16.1.25...
Connected to mta.example.com.
Escape character is '^]'.
220 mta.example.com ESMTP Sendmail 8.13.8/8.13.8; Sat, 14 Jun 2008 23:27:53 +0900 (JST)
ehlo mail
250-mta.example.com Hello fw.foobar.net [192.168.100.100], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-AUTH LOGIN PLAIN
250-DELIVERBY
250 HELP
auth plain c29xxxxxxxxxxxxxxxxxxxxxxxxxxxx0
235 2.0.0 OK Authenticated
mail from: hoge@example.com
250 2.1.0 hoge@example.com... Sender ok
rcpt to: hoge@example.co.jp
250 2.1.5 hoge@example.co.jp... Recipient ok
data
354 Enter mail, end with "." on a line by itself
.
250 2.0.0 m5EERrsc002023 Message accepted for delivery
quit
221 2.0.0 mta.example.com closing connection
Connection closed by foreign host.
$



当然のことですが、sendmailでSMTP-Authを使用するには、ここに書いた以外に、cyrus-saslとの連携のための設定も必要です。その辺のことはこちらのページで詳しく解説されています。

サーバー構築・運用に関わるプロフェッショナルの方々の体験談や解説がいっぱい集まった、
こちら↓のページも合わせてご参照ください。
ブログランキング

テーマ:ソフトウェア - ジャンル:コンピュータ

08:15:59 | Unix/Linux | トラックバック(0) | コメント(0) | page top↑
<<sendmailでRCPT TO後のレスポンスが遅い | ホーム | /kernel: file: table is full>>
コメント
コメントの投稿














管理者にだけ表示を許可する

トラックバック
トラックバックURL
http://iamse.blog110.fc2.com/tb.php/102-28689a86
この記事にトラックバックする(FC2ブログユーザー)
| ホーム |