note 90132 deleted from function.imap-fetchstructure by thiago
| From: | thiago@php.net | Date: | Tue, 07 Apr 2009 18:02:08 +0000 |
| Subject: | note 90132 deleted from function.imap-fetchstructure by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-152917@lists.php.net to get a copy of this message | ||
Note Submitter: phpnet at totalgood dot com
----
Here's the script I used to test the modified version of David's IMAP email parsing script
(David at Hundsness dot com, message # 85685):
<?
// test_decode_email.php
// by Hobson Lane, http://totalgood.com
// 2009-04-07
include_once ("decode_email.php");
# edit this line if you do not want to use a gmail:
$em = '{imap.gmail.com:993/imap/ssl/novalidate-cert}';
# replace this string with your e-mail account password:
$pw = 'your_password';
# replace thise string with your e-mail account user name:
$un = 'your_name@gmail.com';
$mbox = imap_open($em.'INBOX',$un,$pw)
or die("can't connect: " . imap_last_error());
# get an overview of the mailbox, including the number of messages
$ov = imap_check($mbox);
echo "Fetching e-mail inbox overview, this could take a long time ...";
# probably want to do some client-side processing while you wait for this...
$result = imap_fetch_overview($mbox,"1:{$ov->Nmsgs}",0);
echo( count($result) . " messages to process...<br />\n" );
foreach ($result as $ov) {
echo "<br />\n<br />\n<br />\nNo:{$ov->msgno} ";
echo "ID:{$ov->message_id} UID:{$ov->uid}<br />\n";
echo "From:{$ov->from} Subject:{$ov->subject}<br />\n";
list($htmlmsg, $plainmsg, $charset, $attachments) =
decode_email($mbox, $ov->msgno);
echo "charset:<br />\n$charset<br />\n<br />\n";
echo "htmlmsg:<br />\n$htmlmsg<br />\n<br />\n";
echo "plainmsg:<br />\n$plainmsg<br />\n<br />\n";
foreach($attachments as $fn => $a) {
echo "Found attachment named: $fn:<br />\n";
echo "size: ".strlen($a)."<br />\n<br />\n";
}
} # foreach($result...
imap_close($mbox);
?>