tags:

views:

105

answers:

1

Hi

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

A: 

Worst case, you can parse the headers yourself with something like:

<?php
$headers=imap_fetchheader($imap, $msgid);
preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $headers, $matches);
?>

$matches will contain 3 arrays:

$matches[0] are the full-lines (such as "To: [email protected]\r\n")
$matches[1] will be the header (such as "To")
$matches[2] will be the value ([email protected])

Got this from: http://www.php.net/manual/en/function.imap-fetchheader.php#82339

Matt Williamson
This is my header:MIME-Version: 1.0Received: by 10.227.37.212; Wed, 21 Jul 2010 12:21:40 -0700 (PDT)Date: Wed, 21 Jul 2010 12:21:40 -0700Message-ID: Subject: Customise Gmail with colours and themesFrom: Gmail Team To: Frederik Heyninck Content-Type: multipart/alternative; boundary=0016e6d5fc53164fb6048beab667So no email address. That is the problem.
Frederik Heyninck