Author Topic: Filtering does not work by Diagnostic-Code header  (Read 1753 times)

Offline BK201

  • Newbie
  • *
  • Posts: 1
Filtering does not work by Diagnostic-Code header
« on: August 12, 2023, 11:34:26 AM »
Hello
I am trying to filter incoming emails by the content of the "Diagnostic-Code" header, an example of such a header:

Code: [Select]
Diagnostic-Code: smtp; 550-5.1.1 The email account that you tried to reach does not exist. Please try
 550-5.1.1 double-checking the recipient's email address for typos or
 550-5.1.1 unnecessary spaces. Learn more at
 550 5.1.1  https://support.google.com/mail/?p=NoSuchUser sd2-20020a170906ce2200b00992e2779596si3982608ejb.827 - gsmtp

I am trying to find the phrase "The email account that you tried to reach does not exist", for this purpose I created a rule for filter in the settings, screenshot:


But unfortunately the rule doesn't work. What am I doing wrong. Please help.

Example of an incoming message:
Code: [Select]
Return-path: <>
Envelope-to: support@mysite.com
Delivery-date: Fri, 11 Aug 2023 22:56:31 +0300
Received: from exim by mail.mysite.com with local (Exim 4.92.2)
id 1qUYFL-0003JL-T4
for support@mysite.com; Fri, 11 Aug 2023 22:56:31 +0300
X-Failed-Recipients: kirilll2673@gmail.com
Auto-Submitted: auto-replied
From: Mail Delivery System <Mailer-Daemon@mail.mysite.com>
To: support@mysite.com
Content-Type: multipart/report; report-type=delivery-status; boundary=1691783791-eximdsn-1073901725
MIME-Version: 1.0
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1qUYFL-0003JL-T4@mail.mysite.com>
Date: Fri, 11 Aug 2023 22:56:31 +0300

--1691783791-eximdsn-1073901725
Content-type: text/plain; charset=us-ascii

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  kirilll2673@gmail.com
    host gmail-smtp-in.l.google.com [173.194.79.26]
    SMTP error from remote mail server after RCPT TO:<kirilll2673@gmail.com>:
    550-5.1.1 The email account that you tried to reach does not exist. Please try
    550-5.1.1 double-checking the recipient's email address for typos or
    550-5.1.1 unnecessary spaces. Learn more at
    550 5.1.1  https://support.google.com/mail/?p=NoSuchUser sd2-20020a170906ce2200b00992e2779596si3982608ejb.827 - gsmtp

--1691783791-eximdsn-1073901725
Content-type: message/delivery-status

Reporting-MTA: dns; mail.mysite.com

Action: failed
Final-Recipient: rfc822;kirilll2673@gmail.com
Status: 5.0.0
Remote-MTA: dns; gmail-smtp-in.l.google.com
Diagnostic-Code: smtp; 550-5.1.1 The email account that you tried to reach does not exist. Please try
 550-5.1.1 double-checking the recipient's email address for typos or
 550-5.1.1 unnecessary spaces. Learn more at
 550 5.1.1  https://support.google.com/mail/?p=NoSuchUser sd2-20020a170906ce2200b00992e2779596si3982608ejb.827 - gsmtp

--1691783791-eximdsn-1073901725
Content-type: message/rfc822

Return-path: <support@mysite.com>
Received: from admin by mail.mysite.com with local (Exim 4.92.2)
(envelope-from <support@mysite.com>)
id 1qUYFL-0003JC-LG
for kirilll2673@gmail.com; Fri, 11 Aug 2023 22:56:31 +0300
To: kirilll2673@gmail.com
Subject: =?utf-8?B?0JDQutGC0LjQstCw0YbQuNGPINCw0LrQutCw0YPQvdGC0LA=?=
X-PHP-Originating-Script: 1002:class.phpmailer.php
Date: Fri, 11 Aug 2023 22:56:31 +0300
From: support@mysite.com
Message-ID: <rtHCl2ByGVTMsX4BKqj3knrULGixs5FIyoBqxWw4@anitokyo.org>
X-Mailer: DLE CMS
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64

Offline Dmitry42

  • Full Member
  • ***
  • Posts: 232
Re: Filtering does not work by Diagnostic-Code header
« Reply #1 on: August 12, 2023, 10:35:48 PM »
Open your INBOX and select gmail error message. At top of message (under string FROM) you can see links: Details Headers.
Click on Headers - and you can see all headers of this message. I think you can't see here header "Diagnostic-Code"

So I think your string with "Diagnostic-Code" its not header - its just message body then you must use filter "BODY contains".