|
Posted by "Richard Lynch" on 10/16/62 11:19
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
Navigation:
[Reply to this message]
|