I am puzzling over why postfix fails to pass a response from gmail at the end of an outgoing transmission through to smtp_delivery_status_filter.
I am trying to trap a transient failure code response from gmail and replace it with a permanent code and to do this I am using smtp_delivery_status_filter=pcre:/etc/postfix/smtp_dsn_filter. To debug it I am running smtp with -v. I give two real-life (obfuscated) examples below which happened seconds apart. In example 1 - a message successfully sent to gmail - the final response from gmail is passed to the filter, which (correctly) fails to find the text in the filter.. In example 2 - with the dsn code I want to rewrite - nothing is passed to the filter. I am wondering if postfix gets confused either by the length of the response or by gmail's use of a dash between the 3 digit dsn code and enhanced dsn code that follows (although the final line of the response does not have this dash)? # Example 1: response from gmail at end of smtp transmission is checked using dns_filter_lookup - as intended, and not found - as intended 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: > gmail-smtp-in.l.google.com[74.125.195.27]:25: QUIT 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: smtp_stream_setup: maxtime=600 enable_deadline=0 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: < gmail-smtp-in.l.google.com[74.125.195.27]:25: 250 2.0.0 OK 1484049070 ld4si1455293wjb.62 - gsmtp 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: dsn_filter_lookup: 2.0.0 250 2.0.0 OK 1484049070 ld4si1455293wjb.62 - gsmtp 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: dict_pcre_lookup: /etc/postfix/smtp_dsn_filter: 2.0.0 250 2.0.0 OK 1484049070 ld4si1455293wjb.62 - gsmtp 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: maps_find: smtp_delivery_status_filter: 2.0.0 250 2.0.0 OK 1484049070 ld4si1455293wjb.62 - gsmtp: not found 2017-01-10 12:51:10 vps1 postfix/smtp[27587]: C636E43D7C: to=<sarahtimedi...@gmail.com>, orig_to=<sa...@timedicer.co.uk>, relay=gmail-smtp-in.l.google.com[74.125.195.27]:25, delay=0.65, delays=0.05/0.07/0.16/0.37, dsn=2.0.0, status=sent (250 2.0.0 OK 1484049070 ld4si1455293wjb.62 - gsmtp) # Example 2: response from gmail at end of smtp transmission is never checked using dns_filter_lookup - why? 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: > gmail-smtp-in.l.google.com[74.125.195.27]:25: QUIT 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: smtp_stream_setup: maxtime=600 enable_deadline=0 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: < gmail-smtp-in.l.google.com[74.125.195.27]:25: 421-4.7.0 [163.133.227.220 15] Our system has detected that this message is 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: < gmail-smtp-in.l.google.com[74.125.195.27]:25: 421-4.7.0 suspicious due to the very low reputation of the sending domain. To 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: < gmail-smtp-in.l.google.com[74.125.195.27]:25: 421-4.7.0 best protect our users from spam, the message has been blocked. 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: < gmail-smtp-in.l.google.com[74.125.195.27]:25: 421-4.7.0 Please visit 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: < gmail-smtp-in.l.google.com[74.125.195.27]:25: 421 4.7.0 https://support.google.com/mail/answer/188131 for more information. c28si1314741wrb.13 - 2017-01-10 12:52:40 vps1 postfix/smtp[27587]: 7A00F43D7C: host gmail-smtp-in.l.google.com[74.125.195.27] said: 421-4.7.0 [163.133.227.220 15] Our system has detected that this message is 421-4.7.0 suspicious due to the very low reputation of the sending domain. To 421-4.7.0 best protect our users from spam, the message has been blocked. 421-4.7.0 Please visit 421 4.7.0 https://support.google.com/mail/answer/188131 for more information. c28si1314741wrb.13 - gsmtp (in reply to end of DATA command)