Mail sent @ ".date("H").":".date("i").":".date("s")
." - $subject
".writeForm( $from_em, $to_em, $subject, $body );
}
else
{
$feedback = "Please fill in all fields of the form.. Mail not sent
"
.writeForm( $from_em, $to_em, $subject, $body );
}
if($feedback!="") { $feedback ="
$feedback
"; }
}
// The send form
function writeForm( $from_em, $to_em, $subject, $body )
{
// if you don't want to allow sending mail, uncomment the next line:
// return "";
$theform=<<<__END__
__END__;
return $theform;
}
// Cycle through the messages and display message and form
$mbox = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX", $my_email, $my_password)
or die("can't connect: " . imap_last_error());
$num_mgs = imap_num_msg($mbox);
echo<<<__END__
Number of messages: $num_mgs | Max to display: $max | Truncate at: $size characters |
Check for new mail
$feedback
Is QG helping you? Say 'Thank You' at The QG Page.
__END__;
$start=max(1, ${num_mgs}-$max+1);
$result = array_reverse( imap_fetch_overview($mbox,"${start}:${num_mgs}",0) );
foreach ($result as $overview) {
$num = $overview->msgno;
$header = imap_header($mbox, $num);
$from = $header->from;
foreach ($from as $id => $object) {
$fromname = $object->personal;
$fromaddress = $object->mailbox . "@" . $object->host;
}
$subject= $overview->subject;
$body = strip_tags ( imap_fetchbody($mbox,$num,"1") );
if(strlen($body)>$size) { $body = substr($body, 0, $size)."[..TRUNCATED..]"; }
$body = nl2br( $body ) . writeForm( $my_email, $fromaddress, "Re: $subject",
"\n\n\n\n---- Original Message ----\n\n$body" );
echo<<<__END__
From: $fromaddress ($fromname)
Subject: $subject
Date: {$overview->date}
__END__;
}
echo<<<__END__
__END__;
imap_close($mbox);
?>