我正在尝试获取电子邮件正文并根据它向学习者发送回复。但是我Notice: Undefined property: stdClass::$subject
在执行我的代码时遇到了错误。我真的很迷茫,不知道该怎么办。我在下面发布代码。
<?php
$server = '{imap.aaa.com:993/imap/ssl}INBOX';
$username = 'aaa@bbb.com';
$password = 'aaaaaa';
require_once '../swift/lib/swift_required.php';
$connection = imap_open($server,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
$result = imap_search($connection,'ALL');
if($result) {
$output = '';
rsort($result);
foreach($result as $email_number) {
$overview = imap_fetch_overview($connection,$email_number,0);
$message = imap_fetchbody($connection,$email_number,2);
$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
$output.= '<span class="from">'.$overview[0]->from.'</span>';
$output.= '<span class="date">on '.$overview[0]->date.'</span>';
$output.= '</div>';
$output.= '<div class="body">'.$message.'</div>';
if ($message == signup)
{
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message1 = Swift_Message::newInstance('new message')
->setFrom(array('aaa@aaa.com' => 'name'))
->setTo(array('bbb@aaa.com'))
->setBody($message);
$mail = $mailer->send($message1);
}
}
}
else
{
echo "false return";
}
?>