0

A simple notification is like this, this is one of the mail in my mailbox, it mix with other normal email ,but since it seems it generate by server, so i can not see any standard in it. are there any indication that the mail is bounce(in yahoo, gmail , hotmail) so that i can use php to filter out all of them?

This is an automatically generated Delivery Status Notification

THIS IS A WARNING MESSAGE ONLY.

YOU DO NOT NEED TO RESEND YOUR MESSAGE.

Delivery to the following recipient has been delayed:

    saad@asd.com

Message will be retried for 2 more day(s)

Technical details of temporary failure:
The recipient server did not accept our requests to connect. Learn more at http://support.google.com/mail/bin/answer.py?answer=7720
[asd.com (1): Connection timed out]

----- Original message -----

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
       d=gmail.com; s=20120113;
       h=message-id:date:subject:from:to:mime-version:content-type;
       bh=xAGZvwfEEefGGRgBmLS9pzSumiQ/oasFH6Lc3Z0fNT8=;
       b=iB4u5m7ShMuwoZjkK17J+ffZJ1j5Fm5UZTIKCDUcCOt/Diy+a303Or+9x4OCBr0HQW
        dlnQ2A462bU1wjN84bIXWU0J+Nz4lNsc1F0DioJBVnlGC2BB0P8eGKXFRyKRU8E+yaAl
        nyjwYG05RqXzwtL0g8l0UPeQT7TvrjSOgX8xFiPYOLuCY0UKEBU9M3OsqcyErtB8Sadt
        yY7gdUhN6m4gkH83UV7Gxdk/ub9UE+v9PxzukwXKhd1V5pHLB8ErI5NC2QygX+X7AE/Q
        VghpEWJwEl6/5HVSJp0pCECbDqkuBSQ+/P2J7Up+9aPAAf1y5PQLWlS6incEJr97MgG6
        DTdw==
Received: by 10.68.238.3 with SMTP id vg3mr53910310pbc.140.1332778023318;
       Mon, 26 Mar 2012 09:07:03 -0700 (PDT)
Return-Path: <foodilnew@gmail.com>
Received: from [::1] (42-2-253-210.static.netvigator.com. [42.2.253.210])
       by mx.google.com with ESMTPS id n7sm8175644pbk.56.2012.03.26.09.07.01
       (version=SSLv3 cipher=OTHER);
       Mon, 26 Mar 2012 09:07:02 -0700 (PDT)
Message-ID: <1332778007.4f709417422d1@localhost>
Date: Mon, 26 Mar 2012 18:06:42 +0200
Subject: asd
From: asdd <foodilnew@gmail.com>
To: saad@asd.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_=_swift_v4_13327780024f70941258e4f_=_"

sadsda

Updated

$message = Swift_Message::newInstance()
  ->setSubject($row['Subject'])
  ->setReturnPath('fypboune@gmail.com')
  ->setFrom(array($row['ReplyTo'] => $row['FromName']))
  ->setBody($html, 'text/html')
  ->addPart($txt, 'text/plain');
  ;

The error delivery mail will go to my sender account no matter i have specific a return path in it, how to fix that? Thanks

Leo Chan
  • 4,217
  • 8
  • 31
  • 47
  • Check out http://stackoverflow.com/questions/9436584/retrieve-of-the-bounce-mail-in-php/9440480#9440480 and the reference in that answer as well as this answer http://stackoverflow.com/questions/9137370/how-to-manage-emails-bouncing-and-errors-in-php/9137712#9137712 – drew010 Mar 29 '12 at 07:47

1 Answers1

1

what most of do is set a ReturnPath address for the sent mail, any mail that goes to that address is returned by the server not a human, so scan that for error messages added by the server.

$pattern_subject = "#delivery errors|delivery failure|delivery has failed|delivery notification|delivery problem|delivery status notif|failure delivery|failure notice|mail delivery failed|mail delivery system|mail status report|mail system error|mail transaction failed|mailserver notification|mdaemon notification|nondeliverable mail|returned email|returned mail|returned mail|returned to sender|returning message to sender|spam eater|undeliverable|undelivered mail|warning: message#i";

$pattern_body = "#554 delivery error|554 TRANSACTION FAILED|Action: failed|Delivery attempts will continue to be made for|delivery temporarily suspended|Invalid recipient|is not a valid mailbox|Mail rejected by Windows Live Hotmail for policy reasons|mailbox is full|Mailbox quota usage exceeded|mailbox unavailable|my badmailfrom list|no mailbox here by that name|no such address|No such user here|not yet been delivered|Over quota|PERM_FAILURE: DNS Error: Domain name not found|Recipient address rejected|retry timeout exceeded|Status: 4.4.1|The account or domain may not exist, they may be blacklisted, or missing the proper dns entries.|The following address doesn't exist|The message that you sent was undeliverable to the following|The recipient name is not recognized|This Gmail user does not exist|This is a permanent error|Unrouteable address|unrouteable mail domain|User mailbox exceeds allowed size|User unknown in virtual alias table|User unknown#i";
  • Are you referring to VERP? That's a good practice for mailing lists, etc, but of course, it doesn't help for mail you have already received. – tripleee Mar 29 '12 at 03:45
  • what are the phrase i need to search? Since all error message from different mail provider is different . Thank you – Leo Chan Mar 29 '12 at 04:36
  • Also, then you means i need to set up one mail account for one campaign? – Leo Chan Mar 29 '12 at 04:37
  • the only other possible solution will be to write regular expression for all known email host ( gmail,yahoo etc) to extract recipient – Mr Coder Mar 29 '12 at 04:38
  • 1
    @Leo, i have added a couple of search pattern strings i use. –  Mar 29 '12 at 05:11
  • Thank you a lot and i have to create one account for one campaign, or any other easier (but complex in filtering,perharps) way? – Leo Chan Mar 29 '12 at 05:39
  • Also, i am wondering what should i do if some advertising mail sent to that account? Thanks – Leo Chan Mar 29 '12 at 06:05
  • i send all email to @return.mydomain.com to a script then filter the address to determine the campaign, then scan the body for what i need, remember the before @ can be 64 characters, so you can put a lot of data in there (campaign id, user id, etc). google VERP for more –  Mar 29 '12 at 06:10
  • "Also, i am wondering what should i do if some advertising mail sent to that account" never had any non return by machine mail turning up, after some several years, so i wouldn't worry about it. –  Mar 29 '12 at 06:11
  • 1
    as your using swiftmailer: http://pookey.co.uk/wordpress/archives/183-using-verp-with-swiftmailer-symfony-and-exim –  Mar 29 '12 at 06:18