Parsing original headers from a forwarded e-mail.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Parsing original headers from a forwarded e-mail.

Post 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,
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post 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".
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post 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 :)
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post 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,
Post Reply