Get from email address with email parser
<p>I am using this absolute amazing piece of code: <a href="https://github.com/plancake/official-library-php-email-parser/blob/master/PlancakeEmailParser.php" rel="nofollow">https://github.com/plancake/official-library-php-email-parser/blob/master/PlancakeEmailParser.php</a></p>

<p>But the one thing it is missing is the ability to get the From email address. </p>

<p>I have simple added:</p>

<pre><code>public function getFromEmail()
{
    if (!isset($this-&gt;rawFields['from']))
    {
        return false;
    }

    return $this-&gt;rawFields['from'];
}
</code></pre>

<p>But how would I get only the email address part at the moment it returns: <code>John Smith&lt;john@gmail.com&gt;</code>?</p>

<p>Also I would need this to work if the From address was only <code>john@gmail.com</code>?</p>

<p>Thanks to the answers this was the finished code:</p>

<pre><code>public function getFromEmail()
{
    $email = trim($this-&gt;rawFields['from']);

    if(substr($email, -1) == '&gt;'){
        $fromarr = explode("&lt;",$email);
        $mailarr1 = explode("&gt;",$fromarr[1]);
        $email = $mailarr1[0];
    }

    return $email;
}
</code></pre>
