IMAP应用DEMO!用php收邮件
时间:2007-02-17 来源:PHP爱好者
list.php3
<?php
$mbox = imap_open("{localhost/pop3:110}INBOX","wangsu","passwd");
if(!$mbox){
echo "Error on openning mailbox,Exit";
exit();
} else {
$check_array = imap_check($mbox);
echo "当前邮件数:".$check_array->Nmsgs."
";
for($i=1;$i<=$check_array->Nmsgs;$i++){
$msg_structure = imap_fetchstructure($mbox,$i);
$foo=imap_header($mbox,$i);
$from_array=$foo->from;
$fr_array=$from_array[0];
$personal = $fr_array->personal;
$mailbox = $fr_array->mailbox;
$host = $fr_array->host;
$from_address=$mailbox."@".$host;
echo "标题: <a href='showmail.php3?mailid=".$i."'>".$foo->Subj
ect." ";
echo "发件人: $personal
".$msg_structure->bytes."字节
";
}
imap_close($mbox);
}
?>
showmail.php3
<?php
$mbox = imap_open("{localhost/pop3:110}INBOX","wangsu","passwd");
if(!$mbox){
echo "Error on openning mailbox,Exit";
exit();
} else {
$check_array = imap_check($mbox);
if($mailid=="" || $mailid<1 || $mailid > $check_array->Nmsgs)
exit();
$foo=imap_header($mbox,$mailid);
$from_array=$foo->from;
$fr_array=$from_array[0];
$personal = $fr_array->personal;
$mailbox = $fr_array->mailbox;
$host = $fr_array->host;
$from_address=$mailbox."@".$host;
echo "标题: ".$foo->Subject." ";
echo "发件人: $personal $from_address
";
echo "
正文......
<pre>";
$body = imap_body($mbox,$mailid);
$body = imap_qprint($body);
echo $body."</pre>";
imap_close($mbox);
}
?>
非常全面的一个php技术网站,php爱好者站 http://www.phpfans.net 有相当丰富的文章和源代码.
<?php
$mbox = imap_open("{localhost/pop3:110}INBOX","wangsu","passwd");
if(!$mbox){
echo "Error on openning mailbox,Exit";
exit();
} else {
$check_array = imap_check($mbox);
echo "当前邮件数:".$check_array->Nmsgs."
";
for($i=1;$i<=$check_array->Nmsgs;$i++){
$msg_structure = imap_fetchstructure($mbox,$i);
$foo=imap_header($mbox,$i);
$from_array=$foo->from;
$fr_array=$from_array[0];
$personal = $fr_array->personal;
$mailbox = $fr_array->mailbox;
$host = $fr_array->host;
$from_address=$mailbox."@".$host;
echo "标题: <a href='showmail.php3?mailid=".$i."'>".$foo->Subj
ect." ";
echo "发件人: $personal
".$msg_structure->bytes."字节
";
}
imap_close($mbox);
}
?>
showmail.php3
<?php
$mbox = imap_open("{localhost/pop3:110}INBOX","wangsu","passwd");
if(!$mbox){
echo "Error on openning mailbox,Exit";
exit();
} else {
$check_array = imap_check($mbox);
if($mailid=="" || $mailid<1 || $mailid > $check_array->Nmsgs)
exit();
$foo=imap_header($mbox,$mailid);
$from_array=$foo->from;
$fr_array=$from_array[0];
$personal = $fr_array->personal;
$mailbox = $fr_array->mailbox;
$host = $fr_array->host;
$from_address=$mailbox."@".$host;
echo "标题: ".$foo->Subject." ";
echo "发件人: $personal $from_address
";
echo "
正文......
<pre>";
$body = imap_body($mbox,$mailid);
$body = imap_qprint($body);
echo $body."</pre>";
imap_close($mbox);
}
?>
非常全面的一个php技术网站,php爱好者站 http://www.phpfans.net 有相当丰富的文章和源代码.
相关阅读 更多 +