php imap get from email address

Frederik Heyninck picture Frederik Heyninck · Aug 8, 2010 · Viewed 32.3k times · Source

How do I retrieve the email address from an email with imap_open?

If the sender name is known I get the sender name instead of the email address if I use the 'from' parameter.

Code: http://gist.github.com/514207

Answer

dlo picture dlo · Jan 18, 2011
$header = imap_headerinfo($imap_conn, $msgnum);
$fromaddr = $header->from[0]->mailbox . "@" . $header->from[0]->host;