I am trying to fetch an email body and send a reply to the learner based on it. But i am getting an error Notice: Undefined property: stdClass::$subject
while executing my code. I am really lost not knowing what to do. I am posting the code below.
<?php
$server = '{imap.aaa.com:993/imap/ssl}INBOX';
$username = '[email protected]';
$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('[email protected]' => 'name'))
->setTo(array('[email protected]'))
->setBody($message);
$mail = $mailer->send($message1);
}
}
}
else
{
echo "false return";
}
?>
$overview[0]->subject
is not defined :) sovar_dump($overview[0])
would be the next course of action. – Deaton