Я хочу получить подробную информацию по электронной почте из моей учетной записи Gmail и сохранить ее в Mysql Table. Я хочу получать электронные письма на основе UID. Но я не получаю требуемых результатов. Может кто-нибудь сказать мне, как я могу получить электронную почту, тему, текст письма, когда на мою учетную запись Gmail приходит новое письмо. Вот мой код:
/* connect to server */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'myemail';
$password = 'mypassword';
/* try to connect */
$inbox = imap_open($hostname,$username,$password,OP_READONLY) or die('Cannot connect to Tiriyo: ' . imap_last_error());
//echo $inbox;
/* grab emails */
//$emails = imap_search($inbox,'ALL');
$latest_uid = 16; // Last UID inserted in my table
$emails = imap_search($inbox, 'ALL', SE_UID);
print_r($emails);
/* if emails are returned, cycle through each... */
if($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
/* for every email... */
foreach($emails as $email_number) {
//$email_number=$emails[0];
//print_r($emails);
/* get information specific to this email */
$message = imap_fetchbody($inbox,$email_number, 1);
//echo $message;
$overview = imap_fetch_overview($inbox,"1:{$email_number}");
// $message = imap_fetchbody($inbox,$email_number,2);
/* output the email header information */
// $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
$output.= '<span class="subject">'.$overview->subject.'</span> ';
$output.= '<span class="from">'.$overview->from.'</span>';
$output.= '<span class="from">'.$overview->uid.'</span>';
$output.= '</div>';
/* output the email body */
$output.= '<div class="body">'.$message.'</div>';
}
echo $output;
}
/* close the connection */
imap_close($inbox);
Я получаю ошибку:
Notice: Trying to get property of non-object in C:\xampp\htdocs\imap\custom\index2.php on line 37
Notice: Trying to get property of non-object in C:\xampp\htdocs\imap\custom\index2.php on line 38
Notice: Trying to get property of non-object in C:\xampp\htdocs\imap\custom\index2.php on line 41
это строка 37:
$output.= '<span class="subject">'.$overview->subject.'</span> ';