Postfix Sendmail – Troubleshooting Mail Bounces in Ubuntu

email-bouncesPHPpostfixUbuntu

The emails are not being sent to email addresses with domainname.co as domain name.

I have in Ubuntu system three users namely root, ubuntu & domainname.

The following is the log(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

The content of the /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

I am checking this with below script.

$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";
}

UPDATE: The current answer will not help as the error code changed after some configuration changes in main.cf file.

Best Answer

The message:

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))

means that the SMTP server in.hes.trendmicro.com[54.219.191.21] is rejecting messages because they are coming from a source IP address listed in Dynamic/Dialup Users List. Most mail servers only accept messages coming from static IP addresses to reduce spam traffic.

According to instructions provided here, you may need to talk to your internet provider and ask them to remove your IP address from ERS-DUL blacklist:

Dynamic User List (DUL) Database This contains IP addresses or an IP block from ISPs for their dial-up users who have been spam sources.

To remove an IP from the database, users should do any of the following:

  • Contact the ISP, who will then make a request via:

    Provide the reason why you want to remove the IP address(es).

  • Configure the mail client on their own mail server to relay outbound mail through the ISP's designated mail relay.