Processing [email protected] emails via IMAP

I process bounce emails (rollbacks / refunds after sending to a non-existent email address), trying to save them to my MySQL table. From the emails taken: the subject of the email, the text of the message, the address where the email was not sent and the rollback came. And here's the last thing I just don't know how to determine, because all the rollback emails in my mailbox have the address: [email protected], where site.ru -my site's domain (site.ru of course, taken as an example, the domain I have other).

It turns out that this mail daemon on my mail server sends me rollbacks?

How can I find the recipient address in the email then-i.e., the email address of the email that was not sent earlier and I received a rollback in the return message.

Author: Enshtein, 2015-11-24

1 answers

Properly formatted "rollback messages" (Delivery Status Notifications) have a separate MIME container of type Content-Type: message/delivery-status, which follows the format described in RFC. You are interested in Original-Recipient and Final-Recipient.

 1
Author: Outtruder, 2015-11-24 14:03:31