栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

PHP IMAP解码消息

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PHP IMAP解码消息

imap_bodystruct()或imap_fetchstructure()应该将此信息返回给您。以下代码可以完全满足您的需求:

<?php$hostname = '{********:993/imap/ssl}INBOX';$username = '*********';$password = '******';$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());$emails = imap_search($inbox,'ALL');if($emails) {    $output = '';    rsort($emails);    foreach($emails as $email_number) {        $overview = imap_fetch_overview($inbox,$email_number,0);        $structure = imap_fetchstructure($inbox, $email_number);        if(isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) { $part = $structure->parts[1]; $message = imap_fetchbody($inbox,$email_number,2); if($part->encoding == 3) {     $message = imap_base64($message); } else if($part->encoding == 1) {     $message = imap_8bit($message); } else {     $message = imap_qprint($message); }        }        $output.= '<div >';        $output.= '<span >From: '.utf8_depre(imap_utf8($overview[0]->from)).'</span>';        $output.= '<span >on '.utf8_depre(imap_utf8($overview[0]->date)).'</span>';        $output.= '<br /><span >Subject('.$part->encoding.'): '.utf8_depre(imap_utf8($overview[0]->subject)).'</span> ';        $output.= '</div>';        $output.= '<div >'.$message.'</div><hr />';    }    echo $output;}imap_close($inbox);?>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/615398.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号