
最近、Postfix をテストし、仮想環境で送信専用メール クライアントとして設定しています。いくつかの仮想マシンで設定をいじってみて、ようやく適切な値を入力できました。設定は非常に基本的なもので、以下のコードでは使用しているドメインをマスクします。
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mail.example, localhost.localdomain, localhost
relayhost = smtp-relay.gmail.com
mynetworks = 10.0.0.0/8 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
/etc/hostnameの内容は以下のとおりです
mail.example.com
/etc/hostsの内容は以下のとおりです
127.0.0.1 localhost.localdomain localhost
10.x.x.x mail.example.com mail
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
以下の/etc/mailnameの内容
example.com
しかし、何らかの理由で、この構成はこれらのファイルと一致する別のサーバーと同一ですが、次のような操作を実行してコマンド ラインからメールを送信すると、
echo "testing email" | mail -s "test subject" [email protected]
あるサーバーでは、[メールアドレス]、そしてもう一つはそれが[メールアドレス]。どうしても理解できず、これら 2 つのサーバー間でどことどの設定が異なるのかわかりません (その後、サーバーを再起動し、Postfix サービスを数回再起動しました)。
システム変数か、別の構成ファイルがポーリングされているようです。本当に興味があり、ここで何が起こっているのか理解したいので、どんな情報でも非常に役立ちます。ありがとうございます!
アップデート 1: mail.log の比較と postconf -n の追加
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = mail.example.com, localhost.localdomain, localhost
myhostname = mail.example.com
mynetworks = 10.0.0.0/8 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = smtp-relay.gmail.com
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
Mail.log の比較
- メール01:
uid=1000 from=<operations>
- メール02:
uid=1000 [email protected]
- mail01のメールはユーザー名のみで送信されるため(操作)、postfixはmyoriginを追加して[メールアドレス]。
- mail02 のメールは、送信元として完全な電子メール アドレスを使用して送信されるため、Postfix は myorigin を追加しません。
これらは両方とも、このために新しく作成され、完全に更新された Ubuntu 14.04.3 VM 上で実行されています。この裸のユーザー名が設定されている場所を見つけるにはどこを調べればよいでしょうか? /etc/passwd を確認しましたが、「operations」とだけ表示されています。どこかにファイルか何かが欠けているはずです。何かアイデアはありますか?
答え1
解決しました。何らかの理由で、/etc/mailname が他のサーバーと同一で、ファイルの MD5sum も同じであるにもかかわらず、処理されなかったようです。Postfix 構成がそれを受け入れなかったのです。また、1 つのシステム (動作していなかったシステムで、事後に Postfix をインストールしたもの) では mailutils を使用していましたが、もう 1 つのシステムでは bsd-mailx を使用していました。/etc/mailname の変更を試す前にこれを入れ替えましたが、違いはないようでしたが、念のためメモしておきます。とにかく、/etc/mailname を test などの偽の値に変更し、sudo postfix reload と sudo service postfix restart を実行してから、意図した値 (contoso.com) に戻して、同じ 2 つのコマンドを実行して構成とサービスを更新したところ、なんと意図したとおりに動作しました。ご協力いただいた皆様に感謝します。