I have a PHP script which has the source of an email. I aim to split the headers into variables $To and $From
The issue comes when trying to split the to and from strings up. What I need the script to do is take
From: John <john@somesite.com>
To: Susy <susy@mysite.com>, Steven <steven@somesite.com>, Mary <mary@mysite.com>
and return only the from address and the to addresses which are on my site. I.e.
$From = 'john@somesite.com';
$To = array('susy@mysite.com', 'mary@mysite.com');
So the code needs to turn a string of email addresses into an array and then filter out the ones from other sites. It’s the first part that is proving difficult because of the different ways an email address can be listed in a header.
to get the subject: