Re: eml splitting

From: Date: Thu, 23 Jun 2005 01:01:02 +0000
Subject: Re: eml splitting
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-217449@lists.php.net to get a copy of this message
On Wed, June 22, 2005 1:48 am, david forums said: > > Hi > > Do you are or know where I could find something (already made) to split > eml (getting headers, body) > > I try to have a look on imap extension, but it seems to need an smtp > server connection. <?php $message = "/full/path/to/email/message"; $file = fopen($message) or die("Could not fopen $message"); $headers = array(); $body = array(); $in_headers = true; while (!feof($file)){ $line = fgets($file); if ($in_headers && $line != "\n" && $line != "\r\n"){ $headers[] = $line; } else{ $in_headers = false; $body[] = $line; } } echo "HEADERS:<br />\n", implode("<br />", $headers), "<hr />\n"; echo "BODY: <br />\n", implode("<br />", $body); ?> You could also just keep headers and/or body as a string, by using the concatenation operator instead of [] = I think IMAP might also accept a FILENAME as an argument, and it would work. Read the docs. http://php.net/imap -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#217449) next »