Postfix doesn’t send bounce on reject

postfix

I have a Postfix (2.6) installation on a dedicated server.

When I try to send a message to a non existing domain, I get this line in my mail.log:

postfix/smtpd[11069]: NOQUEUE: reject: RCPT from [..omitted..][x.x.x.x]: 450 4.1.2 <test@nonexistingdomain.com>: Recipient address rejected: Domain not found; from=<bounces@mydomain.com> to=<test@nonexistingdomain.com> proto=ESMTP helo=<test.mydomain.com>

In my configuration I have:

smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_invalid_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, check_client_access hash:/etc/postfix/rbl_override,permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client tor.dnsbl.sectoor.de=127.0.0.1

So, the error in the mail log is correct. At the moment the email is not put in queue and is silently rejected.

Is there a way to send a reject message (a delivery status notification?) to the sender (in the example, bounces@mydomain.com)?

Best Answer

You can use notify_classes

# main.cf
error_notice_recipient = postmaster@example.net
notify_classes = resource, software, policy

Send a simple mail

# echo "Hello world" | swaks -4 --server localhost --from alex@example.net --to user@q1w2e3r4t5y6.com --h-Subject "Test message" --body -
=== Trying localhost:25...
=== Connected to localhost.
<-  220 smtp.example.net ESMTP Postfix
 -> EHLO jenkins.example.net
<-  250-smtp.example.net
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> MAIL FROM:<alex@example.net>
<-  250 2.1.0 Ok
 -> RCPT TO:<user@q1w2e3r4t5y6.com>
<** 450 4.1.2 <user@q1w2e3r4t5y6.com>: Recipient address rejected: Domain not found
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.

Check mail log

# cat /var/log/maillog
Mar 18 14:47:32 ci postfix/postfix-script[24049]: starting the Postfix mail system
Mar 18 14:47:32 ci postfix/master[24050]: daemon started -- version 2.6.6, configuration /etc/postfix
Mar 18 14:47:34 ci postfix/smtpd[24057]: connect from localhost[127.0.0.1]
Mar 18 14:47:34 ci postfix/smtpd[24057]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 450 4.1.2 <user@q1w2e3r4t5y6.com>: Recipient address rejected: Domain not found; from=<alex@example.net> to=<user@q1w2e3r4t5y6.com> proto=ESMTP helo=<jenkins.example.net>
Mar 18 14:47:34 ci postfix/cleanup[24060]: 2543E1C0979: message-id=<20160318144734.2543E1C0979@smtp.example.net>
Mar 18 14:47:34 ci postfix/smtpd[24057]: disconnect from localhost[127.0.0.1]
Mar 18 14:47:34 ci postfix/qmgr[24053]: 2543E1C0979: from=<double-bounce@smtp.example.net>, size=922, nrcpt=1 (queue active)
Mar 18 14:47:34 ci postfix/virtual[24061]: 2543E1C0979: to=<alex@example.net>, orig_to=<postmaster@example.net>, relay=virtual, delay=0.05, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
Mar 18 14:47:34 ci postfix/qmgr[24053]: 2543E1C0979: removed

You will receive something like the following

Return-Path: <double-bounce@smtp.example.net>
X-Original-To: postmaster@example.net
Delivered-To: alex@example.net
Received: by smtp.example.net (Postfix)
        id 2543E1C0979; Fri, 18 Mar 2016 14:47:34 +0000 (UTC)
Date: Fri, 18 Mar 2016 14:47:34 +0000 (UTC)
From: MAILER-DAEMON@smtp.example.net (Mail Delivery System)
To: postmaster@example.net (Postmaster)
Subject: Postfix SMTP server: errors from localhost[127.0.0.1]
Message-Id: <20160318144734.2543E1C0979@smtp.example.net>

Transcript of session follows.

 Out: 220 smtp.example.net ESMTP Postfix
 In:  EHLO jenkins.example.net
 Out: 250-smtp.example.net
 Out: 250-PIPELINING
 Out: 250-SIZE 10240000
 Out: 250-VRFY
 Out: 250-ETRN
 Out: 250-ENHANCEDSTATUSCODES
 Out: 250-8BITMIME
 Out: 250 DSN
 In:  MAIL FROM:<alex@example.net>
 Out: 250 2.1.0 Ok
 In:  RCPT TO:<user@q1w2e3r4t5y6.com>
 Out: 450 4.1.2 <user@q1w2e3r4t5y6.com>: Recipient address rejected: Domain not
     found
 In:  QUIT
 Out: 221 2.0.0 Bye


For other details, see the local mail logfile