How to fetch email, subject and name separately using imap_headers() in php? -


i'm trying fetch email address email account. following script working fine me.

$mbox = imap_open("{mail.b******n.com:143/novalidate-cert}", "myemail@b******n.com", "mypassword"); $headers = imap_headers($mbox); print_r($headers); if ($headers == false) {     echo "call failed<br />\n"; } else {     foreach ($headers $val) {         echo $val . "<br />\n";     } } imap_close($mbox); 

above code returning date, email address (if no name) , subject.

example : [1118] => 1119)13-may-2016 facebook have more friends on (16765 chars)

[1192] =>       1193)25-may-2016 john  re: b****c website feedba (27152 chars)  [1224] =>       1225)30-may-2016 k****n@b***n.c dsr not submitted prop (83005 chars) 

means above code returning email if email has no from: name. there way fetch email addresses only? appreciate if guide me regarding this. thank you

you might want fetch message information imap_fetch_overview:

$mc = imap_check($mbox);  $result = imap_fetch_overview($mbox,"1:{$mc->nmsgs}",0); foreach ($result $overview) {     echo "#{$overview->msgno} ({$overview->date}) - from: {$overview->from}     {$overview->subject}\n"; } imap_close($mbox); 

Comments