how to configure postfix to stop sending “Undelivered Mail Returned to Sender” emails thoroughly

Completely disabling postfix to send the  “Undelivered Mail Returned to Sender” emails seems not an easy thing to do. Postfix sends this kind of notification emails in many situations such as the recipients are not found, the destination host is not found, the remote smtp server refuses to connect, etc.

I followed the method in this post and this post to try to stop postfix from sending the  “Undelivered Mail Returned to Sender” emails.


bounce    unix  -       -       n       -       0       bounce

bounce    unix  -       -       n       -       0       discard

But I still received the failure notification emails now and then.

Sending the delivery status notification emails seems the standard behavior of postfix. There is a configuration parameter notify_classes in /etc/postfix/ that is used to control under what  circumstances the notification emails are sent. I tried to set “notify_classes = bounce”, together with the above configuration change, but still could not prevent postfix from sending the failure notification emails. I tried to set ” notify_classes =”, i.e. an empty value, but still could not let postfix stop sending the notifications. Postfix keeps flooding junk emails into my mailbox. By analyzing the postfix log, I found the notification emails are generated for two kinds of emails: bounced emails and deferred emails. For bounced emails, the discard process now takes charge and does not send the failure report email as we configured in the /etc/postfix/ But for deferred emails, the bounce process is still invoked and it generates the sender non-delivery notification. The solution still lies in the /etc/postfix/ We should change the defer service line as well, from the original bounce command to discard command, as follows.

bounce    unix  -       -       n       -       0       discard
defer     unix  -       -       n       -       0       discard

Note the syntax of is confusing. The first field in a line is the service, which is an abstract concept, while the last field is the specific command. The two lines above tell postfix: when the email being delivered is bounced or deferred, call  the discard commad, which silently ignores the failure and does not send the delivery status notification email to the sender.

Posted in tips of hosting