Trying to read all mail headers in a single preg_match_all
Posted: Fri Feb 03, 2006 2:27 pm
I have an unparsed mail from which I am trying to read parts of it...I am trying to read from/to/date/subject all in a single statement...
Here is the mail from which I am trying to match..
What happens is ...it is greedy and does not actually stop at new lines even after I have specified m modifier
output:
Here is the mail from which I am trying to match..
Code: Select all
<?php
$message = file_get_contents("http://findmoby.com/unparsed_mail.htm");
//print_r($message);
preg_match_all("#(Date|From|To|Subject):(.*?)$#im", $message, $matches);
print_r($matches);
?>output:
Code: Select all
Array
(
[0] => Array
(
[0] => To:
[1] => to:godshalk@gmail.com">godshalk@gmail.com Fri Feb 03 12:53:16 2006Received: from [66.249.92.193] (helo=uproxy.gmail.com) by athena.pronameservice.net with esmtp (Exim 4.52) id 1F563W-00021Z-Qv for bitt3n@findmoby.com; Fri, 03 Feb 2006 12:53:16 -0600Received: by uproxy.gmail.com with SMTP id u2so29148uge for <bitt3n@findmoby.com>; Fri, 03 Feb 2006 10:53:19 -0800 (PST)DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=dyk5dmqU7VHivuZ69z96Nvr7Ln15ZNcqjWopqsMvmfm+f9szF9eCFoLpsCbt09ba2qngHfnP5ouug6/59hCBKhhBccAQbUYo1vZ8saqtjJn6uwhYIxNlKZC0yTbHrqKvzswmR/+vm30ArWVkC/vmkVESFFmHHfbJESwWFyvolnQ=Received: by 10.49.8.5 with SMTP id l5mr606158nfi; Fri, 03 Feb 2006 10:53:18 -0800 (PST)Received: by 10.48.254.3 with HTTP; Fri, 3 Feb 2006 10:53:17 -0800 (PST)Message-ID: <e0632b600602031053hfa1455agdf3520a1605a12d7@mail.gmail.com>Date: Fri, 3 Feb 2006 13:53:17 -0500From: Dirk Godshalk <godshalk@gmail.com>To: bitt3n@findmoby.comSubject: unparsedMIME-Version: 1.0Content-Type: multipart/mixed; boundary="----=_Part_12417_32294437.1138992797880"------=_Part_12417_32294437.1138992797880Content-Type: multipart/alternative; boundary="----=_Part_12418_29668200.1138992797880"
...
...
...
...
...
...