Page 1 of 1

Parsing original headers from a forwarded e-mail.

Posted: Tue Jul 24, 2007 9:25 am
by impulse()
I've hit a bit of a snag here but I know the headers are there somewhere as I can view the original headers from forwarded e-mail through the Gmail service. Can these be viewed with PHPs IMAP functions or is it time to bring in the classes?

Regards,

Posted: Tue Jul 24, 2007 9:41 am
by TheMoose
imap_headerinfo() - http://us.php.net/manual/en/function.im ... erinfo.php
imap_fetchheader() - http://us.php.net/manual/en/function.im ... header.php

Both return header information, it just depends on which format you need the returned values in. The first returns it as a nice object with properties set to their respective values (ie: $obj->fromaddress). The second returns the "unfiltered RFC2822 format header of the specified message".

Posted: Tue Jul 24, 2007 9:46 am
by impulse()
These do contain the headers of the e-mail that's in the mailbox, but it doesn't contain the headers from the original e-mail that was sent to the forwarder, if it was forwarded.

It looks like they're stored in the body section from a second glance. I'm having trouble picking out a certain part now though. Happy days :)

Posted: Wed Jul 25, 2007 6:04 am
by impulse()
I'm still a bit stuck with this at the moment but I may be able to help you help me.

If I highlight multiple e-mails in Microsoft Outlook and then forward them to an address, each selected e-mail gets sent as an attachment. If I view the mail box these were sent to in a webmail service I have the option to 'Display' each attachment, but when I click it I get the option to save the attachments as .EML files (which would suit me fine). But if I view the bodystructure of the e-mail containing the e-mails as attachments, PHP doesn't see those files as .EML files, it sees them all as the same file:
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => us-ascii
Does anybody know a way to use the IMAP functions in PHP to save those files as .EML files?

Regards,