Translated message

A translation of this page exists in English.

Warning message

This translation is outdated. For the most up-to-date information, please refer to the English version.

認証を使用して、ポート 587 でメールを中継するように sendmail を設定する

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.1

Issue

  • SMTP から ISP ドメインに中継するように sendmail ホストを設定する必要があります。メール配信をテストすると以下のエラーが発生します。

    user@xxxx.com...Connecting to smtp.<hostname>.com. via relay
    user@xxxx.com...Deferred:Connection reset by smtp.xxxx.com.
    

ポート 25 はブロックされ、ポート 587 だけが許可されます。

このサーバーにおける設定要件は以下のようになります。

  • このサーバー (ローカルの sendmail サーバー) は、ポート 25 経由で内部アプリケーション (SAP) からメールを受け取ります。
  • アプリケーションからメールを受け取ると、このサーバーはメールを ISP (smtp.XXX.com) に中継します。
  • ローカルの sendmail サーバーは、アプリケーションからのみメール転送を行います。

Resolution

  • 以下の行はコメント化する必要があります。

    "DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl"
    

ローカルの sendmail がポート 25 をリッスンしており、ISP メールサーバーが認証にポート 587 が必要になります。これは、ローカルドメインも認証する必要がある場合のみ必要になります。メールサーバーでの認証に smtp を正しく設定する手順に従ってください。

  • /etc/mail/ ディレクトリに移動します。

    # cd /etc/mail
    
  • ディレクトリを作成します。

    # mkdir auth
    # chmod 700 auth
    
  • 認証情報でファイルを作成します (例では authinfo を使用)

    # vim /etc/mail/auth/authinfo
    以下の行を追加して保存します。
    AuthInfo:smtp.isp-server.com "U:root"   Ï:user"   "P:password"   "M:PLAIN"
    

smtp.example.com をお使いの ISP のホスト名に置き換え、USERNAME フィールドと PASSWORD フィールドに、有効なユーザー名とパスワードを指定します。

  • 認証データベースを作成し、両方のファイルを root だけ読み込めるようにします。

    # cd /etc/mail/auth
    # makemap hash authinfo < authinfo
    # chmod 600 authinfo*
    
  • /etc/mail/sendmail.mc ファイルで以下の行を修正します。

    define(`SMART_HOST',`smtp.isp-server.com')dnl
    define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    FEATURE(`authinfo',`hash /etc/mail/auth/authinfo')dnl
    
  • sendmail サービスを再起動します。

    # service sendmail restart
    
    
    
    sendmail.mc ファイルで利用できるデフォルトの "FEATURE(`authinfo',`Hash -o /etc/mail/authinfo.db')dnl" オプションがあります。
         この行をコメント化するか、削除します。
    
  • "authinfo" ファイルに適切なアクセス権があることを確認します。

  • 以下のコマンドを実行して、重複するエントリを確認します。

    # less etc/mail/sendmail.mc | grep authinfo
    
    
    # less etc/mail/sendmail.mc | grep SMART_HOST
    
    
    # less etc/mail/sendmail.mc | grep confAUTH_MECHANISMS
    
  • 認証をテストするには、以下のコマンドを実行してリモートの MTA にメールを送信します。

    # sendmail -Am -v -t 
    To: email@remote-domain.com
    From: root@localdomain.com
    Subject:Test
    
    Please ingore 
    Ctrl+D
    
    
    email@remote-domain.com
    ...Connecting to remote-domain.com. via relay...
    220 remote-domain.com ESMTP Sendmail 8.13.1/8.13.1; Tue, 11 May 2010 17:08:03 +0530
    >>> EHLO localdomain.com
    250-remote-domain.com Hello localdomain.com [IP-of-localdomain], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ETRN
    250-AUTH LOGIN PLAIN
    250-DELIVERBY
    250 HELP
    >>> AUTH LOGIN
    334 VXNlcm5hbWU6
    >>> dGVzdEBkaGNwMjExLTIzLmdzc2xhYi5wbnEucmVkaGF0LmNvbQ==
    334 UGFzc3dvcmQ6
    >>> eA==
    235 2.0.0 OK Authenticated       <<--------- This is important if authentication is not successful then it will say "authentication failure" and email will not be delivered. 
    >>> MAIL From:< root@localdomain.com> SIZE=100 AUTH= root@domain-name-of-A
    250 2.1.0 < root@localdomain.com>...Sender ok
    >>> RCPT To:< email@remote-domain.com>
    >>> DATA
    250 2.1.5 < email@remote-domain.com>...Recipient ok
    354 Enter mail, end with "." on a line by itself
    >>> .
    250 2.0.0 o4BBc3Ce014542 Message accepted for delivery
     email@remote-domain.com...Sent (o4BBc3Ce014542 Message accepted for delivery)
    Closing connection to remote-domain.com.
    >>> QUIT
    

認証の詳細は以下のナレッジを参照してください。

How to configure sendmail to use a remote smtp server that requires authentification and how to test authentication?

Root Cause

  • smtp サーバーの設定が不完全です。ローカルサーバーは、ポート 587 で接続するために認証の詳細を提供するようには設定されていませんでした。

Diagnostic Steps

  • 先に進むために、潜在的なネットワークの問題を最初に解決することが推奨されます。したがって、メールサーバーがポート 25 の接続を許可しているかどうかを確認します。
  • ローカルの smtp サーバーに接続する前に認証を要求しますか。認証が必要な場合は、詳細な信用情報をすべて取得してください。

  • また、指定したドメインからメールを受け取るようにローカルサーバーを許可するかどうかを確認します。

  • DNS と逆 DNS が設定され、適切に動作していることを確認します。
  • telnet を使用してメールを送信し、問題なく動作するかどうかを確認します。

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments