I am fetching email from gmail where I can fetch body, name of the sender etc. I have to get the email-id of the sender, which I am not able to get. I have tried with some variables names like fromaddress after fetchting headerinfo by imap_header but didn't work. Can I get some help regarding this ?
function connect_mail(){
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '*****@gmail.com';
$password = '*****';
$inbox = imap_open($hostname,$username,$password) or die(t('Cannot connect to Gmail: ' . imap_last_error()));
$emails = imap_search($inbox,'ALL');
$Msgcount = count($emails);
for ($x = 1; $x <= $Msgcount; $x++)
{
$overview = imap_fetch_overview($inbox, $x);
$title = $overview[0]->subject;
echo "Subject of the Mail : ".$title."</br>";
$from = $overview[0]->from;
echo "Name of the sender : ".$from."</br>";
//Now I have to get mail ID of senders & print it, but how?
}
}
I have tried my luck with several methods but got failed each time... Thanks in Advance :)