Forum Moderators: coopster
$email = '
...
From: Display Name <from@domain.com>
Date: Tue, 23 Aug 2016 19:56:48 -0400
Message-ID: <CAKfQz8NQHvunh65vVnusnxHQSkAczCxYzy_3TorWoP+FWgDw@mail.gmail.com>
Subject: Popsicle
To: to@url.com
...';
if(preg_match('/\nTo: (.*)\n/', $email, $match)) $to = $match[1];
if(preg_match('/\nFrom: (.*) <(.*)>\n/', $email, $match)){$user = $match[1];$from= $match[2];}
if(preg_match('/\nSubject: (.*)\n/', $email, $match)) $subj = $match[1];
Are there always spaces after the colon?
Does the from line always have a display name with the email address in brackets?
Does the to line ever have a display name with the email in brackets?
If there are multiple to email addresses will it break the script?
I'm trying to keep this script light weight so I'm not trying to load a large library, but is there a more resilient way to do this?