You are here: Re: [PHP] eml splitting « PHP « IT news, forums, messages
Re: [PHP] eml splitting

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация