<?php
// specification:
$username="emailid";
$password="password";
$mbox = imap_open ("{imap.gmail.com:993/imap/ssl}",$username,$password)
or die("can't connect: " . imap_last_error());
//imap_reopen($connection,'{imap.gmail.com}INBOX');
$list = imap_list($mbox, "{imap.gmail.com:993/imap/ssl}INBOX", "*");
/*$xx=imap_reopen($mbox,'{imap.gmail.com:993/imap/ssl}INBOX');
echo "asdasd".$num_mgs = imap_num_msg($mbox);
$list = imap_list($mbox,"{imap.gmail.com:993/imap/ssl}INBOX", "*");
//$list =imap_getmailboxes($mbox,"{imap.gmail.com:993/imap/ssl}INBOX", "*");
echo "<pre>";
print_r($list);
echo "</pre>";
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Mailboxes</h1>\n";
/*$folders = imap_listmailbox($mbox,"{imap.gmail.com:993/imap/ssl}INBOX","*");
if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
$MC = imap_check($mbox);
// Fetch an overview for all messages in INBOX
$result = imap_fetch_overview($mbox,"1:{$MC->Nmsgs}",0);
foreach ($result as $overview) {
echo "#{$overview->msgno} ({$overview->date}) - From: {$overview->from}
{$overview->subject}\n";
}
*/
$message_count = imap_num_msg($mbox);
for ($i = $message_count; $i== $message_count; $i++) {
/* $header = imap_header($mbox, $i);
$body = trim(substr(imap_body($mbox, $i), 0, 100));
$prettydate = date("jS F Y", $header->udate);
if (isset($header->from[0]->personal)) {
$personal = $header->from[0]->personal;
} else {
$personal = $header->from[0]->mailbox;
}
$email = "$personal <{$header->from[0]->mailbox}@{$header->from[0]->host}>";
echo "On $prettydate, $email said \"$body\".\<br>";*/
//$header=imap_header($mbox,$i);
/*echo "From: $header[fromaddress]<br>";
echo "To: $header[toaddress]<br>";
echo "Date: $header[Date]<br>";
echo "Subject: $header[Subject]<br><br>";*/
echo imap_body($mbox,$i);
}
// pull the plain text for message $n
/*$st = imap_fetchstructure($mbox, $message_count);
if (!empty($st->parts)) {
for ($i = 0, $j = count($st->parts); $i < $j; $i++) {
$part = $st->parts[$i];
if ($part->subtype == 'PLAIN') {
$body = imap_fetchbody($mbox, $message_count,$i+1);
}
}
} else {
$body = imap_body($mbox,$message_count);
}*/
imap_close($mbox);
?>
Friday, April 4, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment