Fetch Emails from Mail Server Using PHP

by Naveenkumar 2014-03-21 13:00:01


Fetch Emails from Mail Server Using PHP

Code :


$con = imap_open("{sitenameRazz
ort/(pop3 | smtp)/novalidate-cert}folder", "username", "password");

for Example,

$con = imap_open("{example.comRazz
ort/pop3/novalidate-cert}INBOX", "example@example.com", "password");


$MC = imap_check($con);

$range = "1:".$MC->Nmsgs;

$response = imap_fetch_overview($con,$range);

foreach ($response as $msg) {

$msgno = $msg->msgno;

$message = imap_fetchbody($con,$msgno,1);

$headerinfo=imap_headerinfo($con, $msgno);

$h = get_object_vars($headerinfo);

$maildate = $h['date'];

$from_mail = $h['from'][0]->mailbox."@".$h['from'][0]->host;

$subject = $h['subject'];

$message_id = $h['message_id'];

}

imap_close($con);



$message Contains Message of the Email

Print this $h variable for all header information of particular mail.



1020
like
0
dislike
0
mail
flag

You must LOGIN to add comments