The Little Guy Posted January 20, 2010 Share Posted January 20, 2010 I have a string that is an email, it contains the headers and everything, it looks like this: From [email protected] Tue Jan 19 23:29:45 2010 Return-Path: <[email protected]> X-Original-To: [email protected] Delivered-To: [email protected] Received: from homiemail-mx6.g.dreamhost.com (mailbigip.dreamhost.com [208.97.132.5]) by wonderwoman.dreamhost.com (Postfix) with ESMTP id 8636DEBA9 for <[email protected]>; Tue, 19 Jan 2010 23:29:45 -0800 (PST) Received: by homiemail-mx6.g.dreamhost.com (Postfix, from userid 10282953) id D1E87EE14F; Tue, 19 Jan 2010 23:35:19 -0800 (PST) X-Original-To: [email protected] Delivered-To: [email protected] Received: from mail-pz0-f188.google.com (mail-pz0-f188.google.com [209.85.222.188]) by homiemail-mx6.g.dreamhost.com (Postfix) with ESMTP id 83473EE08D for <[email protected]>; Tue, 19 Jan 2010 23:35:18 -0800 (PST) Received: by pzk26 with SMTP id 26so89971pzk.26 for <[email protected]>; Tue, 19 Jan 2010 23:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Wf6K8OLoW4/XEDl5ayjd+KifybzS0ShdBuPBNSA1E2Y=; b=dWth6irEgzdEF42h4ioT+INhWx41l3KUmxvAADnahk2eg3o73yDIyRefuAKUMv2ExM Y3SoEC/T7yap9iDtiS9El0wMho0IE8EEXP8H/UR9srRbwgcVasLPITVuBkoLTgprHkE5 uO7oPl3QidBUMK7N9+TDpB0uyH1FfMtB5HM24= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=e20adOspd25HrINZwvPGLmJGsLw3pcq8XjyOUVZNaLsZ0pHo+TtGcnwkwSGdKTIxRL V/IAaUCHLgqt96j0A5FunMS1+v+jnBc2XHKNL462Jt3rqCDZwbp/ycNJlVy962pBmfHe YAVrnuLHjYpJz5t6VsLszTvRGxIUIKkcJ7yhI= MIME-Version: 1.0 Received: by 10.142.151.35 with SMTP id y35mr4401663wfd.310.1263972918206; Tue, 19 Jan 2010 23:35:18 -0800 (PST) Date: Wed, 20 Jan 2010 01:35:18 -0600 Message-ID: <[email protected]> Subject: asdfa From: Ryan Naddy <[email protected]> To: [email protected] Content-Type: multipart/alternative; boundary=000e0cd17c8acba1e5047d93a015 X-DH-Original-To: [email protected] --000e0cd17c8acba1e5047d93a015 Content-Type: text/plain; charset=ISO-8859-1 asdfsafd -- Ryan Naddy Visit one of my sites at: http://viplyrics.com, http://tzfiles.com, or http://phpsnips.com --000e0cd17c8acba1e5047d93a015 Content-Type: text/html; charset=ISO-8859-1 asdfsafd<br clear="all"><br>-- <br>Ryan Naddy<br><br>Visit one of my sites at:<br><a href="http://viplyrics.com">http://viplyrics.com</a>, <a href="http://tzfiles.com">http://tzfiles.com</a>, or <a href="http://phpsnips.com">http://phpsnips.com</a><br> --000e0cd17c8acba1e5047d93a015-- What would be the best way to extract the full header, and message? Link to comment https://forums.phpfreaks.com/topic/189134-email-extract-data/ Share on other sites More sharing options...
The Little Guy Posted January 20, 2010 Author Share Posted January 20, 2010 Got it, did this: // Get header $sections = preg_split("~\n\n~", $this->email); $this->headers = $sections[0]; // Get boundary preg_match("~boundary=(.+?)\n~", $this->email, $matches); $this->boundary = $matches[1]; // Get body $split = preg_split("~--".$this->boundary."~m", $this->email); unset($split[0]); $this->body = "--".$this->boundary . implode("--".$this->boundary, $split); Link to comment https://forums.phpfreaks.com/topic/189134-email-extract-data/#findComment-998532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.