Ubuntu

無法使用 postfix-sendmail 發送郵件並被退回

  • February 22, 2020

電子郵件未發送到以 domainname.co 作為域名的電子郵件地址。

我在 Ubuntu 系統中有三個使用者,即 root、ubuntu 和域名。

以下是日誌(tail /var/log/mail.log -n 20)

Feb 19 04:36:56 server postfix/pickup[22963]: 521A0106D3A: uid=1003 from=<domainname>
Feb 19 04:36:56 server postfix/cleanup[26043]: 521A0106D3A: message-id=<20200219043656.521A0106D3A@server.domainname.co>
Feb 19 04:36:56 server postfix/qmgr[14300]: 521A0106D3A: from=<domainname@domainname.co>, size=357, nrcpt=1 (queue active)
Feb 19 04:36:58 server postfix/smtp[26045]: 521A0106D3A: to=<dushyant.joshi@domainname.co>, relay=in.hes.trendmicro.com[54.219.191.20]:25, delay=1.9, delays=0.01/0.01/1.6/0.21, dsn=5.7.1, status=bounced (host in.hedmicro.com[54.219.191.20] said: 550 5.7.1 <weborders@domainname.co>: Recipient address rejected: ERS-DUL. (in reply to RCPT TO command))
Feb 19 04:36:58 server postfix/cleanup[26043]: 732DD106D41: message-id=<20200219043658.732DD106D41@server.domainname.co>
Feb 19 04:36:58 server postfix/bounce[26046]: 521A0106D3A: sender non-delivery notification: 732DD106D41
Feb 19 04:36:58 server postfix/qmgr[14300]: 732DD106D41: from=<>, size=2368, nrcpt=1 (queue active)
Feb 19 04:36:58 server postfix/qmgr[14300]: 521A0106D3A: removed
Feb 19 04:36:59 server postfix/smtp[26045]: 732DD106D41: to=<domainname@domainname.co>, relay=in.hes.trendmicro.com[54.219.191.21]:25, delay=1.5, delays=0/0/1.3/0.21, dsn=5.7.1, status=bounced (host in.hes.trendmicro.com[54.219.191.21] said: 550 5.7.1 <domainname@domainname.co>: Recipient address rejected: ERS-DUL. (in reply to RCPT TO command))
Feb 19 04:37:00 server postfix/qmgr[14300]: 732DD106D41: removed

/etc/postfix/main.cf的內容

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
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

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = server.domainname.co
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#myorigin = /etc/mailname
myorigin = $mydomain
mydestination = $myhostname, server, localhost.domainname.co, localhost
#smtp_generic_maps = texthash:/etc/postfix/generic
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
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = may
allow_percent_hack = no

我正在用下面的腳本檢查這個。

$sender = 'sales@domainname.co';
$recipient = 'dushyant.joshi@domainname.co';

$subject = "php mail test";
$message = "php test message";
$headers = 'From:' . $sender;

if (mail($recipient, $subject, $message, $headers)) {
       echo "Message accepted";
} else {
       echo "Error: Message not accepted";
}

**更新:**目前的答案將無濟於事,因為在 main.cf 文件中的一些配置更改後錯誤程式碼發生了變化。

消息:

Feb 19 04:36:59 server postfix/smtp[26045]: 732DD106D41: to=<domainname@domainname.co>, relay=in.hes.trendmicro.com[54.219.191.21]:25, delay=1.5, delays=0/0/1.3/0.21, dsn=5.7.1, status=bounced (host in.hes.trendmicro.com[54.219.191.21] said: 550 5.7.1 <domainname@domainname.co>: Recipient address rejected: ERS-DUL. (in reply to RCPT TO command))

表示 SMTP 伺服器in.hes.trendmicro.com[54.219.191.21]拒絕郵件,因為它們來自Dynamic/Dialup Users List中列出的源 IP 地址。大多數郵件伺服器只接受來自靜態 IP 地址的郵件以減少垃圾郵件流量。

根據此處提供的說明,您可能需要與您的網際網路提供商聯繫並要求他們從 ERS-DUL 黑名單中刪除您的 IP 地址:

動態使用者列表 (DUL) 數據庫 這包含來自 ISP 的 IP 地址或 IP 塊,用於作為垃圾郵件來源的撥號使用者。

要從數據庫中刪除 IP,使用者應執行以下任一操作:

  • 聯繫 ISP,後者將通過以下方式提出請求:

+ 電子郵件:dul@mail-abuse.com + 網路表格:全球黑名單例外表格提供您要刪除 IP 地址的原因。

  • 在自己的郵件伺服器上配置郵件客戶端,通過 ISP 指定的郵件中繼中繼出站郵件。

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