Re: eml splitting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux