
我最近一直在測試 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]
一台伺服器顯示它來自[電子郵件受保護],另一個表明它來自[電子郵件受保護]。我一生都無法弄清楚,而且我不確定這兩台伺服器之間的位置和設定有何不同(此後我也重新啟動了它們並重新啟動了 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
郵件日誌比較
- 郵件01:
uid=1000 from=<operations>
- 郵件02:
uid=1000 [email protected]
- mail01 上的郵件是用裸用戶名(操作)提交的,因此 postfix 附加了 myorigin[電子郵件受保護]。
- mail02 上的郵件看起來是以完整的電子郵件地址作為寄件者提交的,因此 Postfix 不會附加 myorigin。
它們都在為此全新創建並完全更新的 Ubuntu 14.04.3 VM 上運行。我可以在哪裡找到這個裸用戶名的配置位置?我檢查了 /etc/passwd 但它只是說“操作”,一定有一個文件或我在某處丟失的東西 - 你有什麼想法嗎?
答案1
我想到了。無論出於何種原因,似乎我的 /etc/mailname 沒有得到處理,即使它與其他伺服器相同 - 並且該檔案甚至具有相同的 MD5sum - Postfix 配置沒有接受它。我還注意到我在一個系統上使用 mailutils(該系統無法正常工作並在事後安裝了 Postfix),而另一個系統則使用 bsd-mailx。我在嘗試更改 /etc/mailname 之前交換了這個,它似乎沒有什麼區別,但為了以防萬一,我注意到它是值得的。無論如何,我將/etc/mailname 更改為類似test 的虛假值,然後執行sudo postfix reload 和sudo service postfix restart ,然後將其切換回我想要的值(contoso.com),然後執行相同的兩個命令刷新配置和服務,你瞧,它正在按預期工作。感謝所有提供幫助的人。