Postfix

當網路伺服器配置為使用 mx 伺服器發送時,mx 記錄伺服器將電子郵件發送回網路伺服器

  • November 13, 2017

我有我的網路伺服器執行一個網路郵件客戶端。我將此 webmail 客戶端配置為使用單獨的獨立郵件伺服器發送電子郵件。我可以成功地從這個 webmail 發送電子郵件到 gmail。

但是,在嘗試將電子郵件發送到我自己域中的地址時,我可以看到我連接到獨立伺服器以將電子郵件作為日誌狀態發送:

Nov 12 12:47:46 mx dovecot: imap(sender@myowndomain.com): Disconnected: Logged out in=291 out=2751
Nov 12 12:48:46 mx dovecot: imap-login: Login: user=<sender@myowndomain.com>, method=PLAIN, rip=192.168.1.11, lip=192.168.1.12, mpid=19294, TLS, session=<6pT3wzxd4QrAqAoM>
Nov 12 12:48:46 mx dovecot: imap(sender@myowndomain.com): Disconnected: Logged out in=291 out=2751

但是,mx 伺服器本身並沒有像接收來自其他域(即 gmail 等)的傳入電子郵件那樣接收電子郵件,而是在顯示郵件日誌的 Web 伺服器上接收到電子郵件:

Nov 12 12:27:12 myservername postfix/pickup[29249]: 3210A1020814: uid=56 from=<sender@mydomain.com>
Nov 12 12:27:12 myservername postfix/cleanup[29254]: 3210A1020814: message-id=<5c688f30a84ffe77a3dr1f2adacd06bb@mydomain.com>
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3210A1020814: from=<sender@mydomain.com>, size=532, nrcpt=1 (queue active)
Nov 12 12:27:12 myservername postfix/local[29256]: 3210A1020814: to=<sender@mydomain.com>, relay=local, delay=0.09, delays=0.06/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "sender")
Nov 12 12:27:12 myservername postfix/cleanup[29254]: 3F1291020816: message-id=<20171112172712.3F1291020816@mydomain.com>
Nov 12 12:27:12 myservername postfix/bounce[29257]: 3210A1020814: sender non-delivery notification: 3F1291020816
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3F1291020816: from=<>, size=2288, nrcpt=1 (queue active)
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3210A1020814: removed
Nov 12 12:27:12 myservername postfix/local[29256]: 3F1291020816: to=<sender@mydomain.com>, relay=local, delay=0.05, delays=0.03/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "sender")
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3F1291020816: removed

後綴的 main.cf:

# 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.

myhostname = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mydomain.com, localhost.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all


smtp_tls_security_level = may

如何獲得獨立的郵件伺服器,我的 mx 記錄配置為將我的 webmail 伺服器郵件客戶端通過它發送的電子郵件發送給它自己,而不是返回給 web 伺服器?

你已經在你的 web 伺服器上配置了 Postfix,通過設置myhostname = mydomain.com. 使用此設置,Postfix 將始終嘗試在本地為命名域傳遞郵件。

這顯然不是你想要的。

相反,您應該簡單地刪除此設置,這將導致 Postfix 改用系統主機名(不應設置為裸域名),從而根據其 MX 記錄為域傳遞郵件。

引用自:https://serverfault.com/questions/883099