· 8 years ago · Jul 27, 2018, 05:42 PM
1imap_headerinfo($connection,$msg);
2
3stdClass Object
4(
5 .
6 .
7 [to] => Array
8 (
9 [0] => stdClass Object
10 (
11 [mailbox] => testemail
12 [host] => gmail.com
13 )
14 )
15)
16
17$connection = imap_open($host,$uname,$pwd) or die(imap_last_error());
18$messages = imap_search($connection,'ALL');
19
20foreach($messages as $msg) {
21 $header = imap_headerinfo($connection,$msg);
22
23 foreach($header->to as $reciever){
24 echo $reciever->mailbox.'@'.$reciever->host.'<br/>';
25 }
26}