Retrieve Previous Email Headers

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
bkozora
Forum Newbie
Posts: 7
Joined: Mon Jun 18, 2007 11:41 am

Retrieve Previous Email Headers

Post by bkozora »

I'm working on an automated bounce detection system that I'll submit to the community. I'm trying to capture the header details of all of the various headers in parts of bounce emails I've retrieved, specifically Swift's message-id to allow database reference. Looking through PHP 5's API docs, I've seen there's methods that return header details. I realize this is for the message swift is about to send, but is there a way to pass my raw headers from another email into swift somewhere and get those methods to return my bounced email's header info? More a question of Swift's internals, but figured it was worth a shot. I've tried everything recently to retrieve the message-id from past email headers (lower level?) to relate the captured bounce and its status to the email sent by Swift, but have yet to uncover a flexible solution. Thanks!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Parsing emails into Swift's MIME object format is something I've wanted to do for a while. It would make it easier to "attach" emails to a swift message and it would also allow emails to be stored and then sent later.

Currently there's no implementation of this however. If all you want is the message ID it's a simple Regex:

Code: Select all

if (preg_match('/^Message-ID: <([^>]+)>/ism', $full_email, $matches))
{
  echo "Message-ID is " . $matches[1];
}
else
{
  echo "There's no Message-ID";
}
bkozora
Forum Newbie
Posts: 7
Joined: Mon Jun 18, 2007 11:41 am

Post by bkozora »

Awesome, thanks a bunch! As soon as I have something notable, I'll post links to my bounce handling code for others to use/modify.
Post Reply