国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

用PHP讀取IMAP郵件

2024-05-04 23:01:02
字體:
來源:轉載
供稿:網友
//這個例子可以練習關于imap的函數
//但是如果真的要寫webmail,那么要考慮的東西就不止這些了……孤狼

login.php3  
<?php  

if (!$php_auth_user) {  
header("www-authenticate: basic realm="郵件客戶檢查"");  
header("http/1.0 401 unauthorized");  
} else {  
$mydir=ereg_replace("/[^/]+$","",$php_self);  
header("location: $server_name$mydir/messages.php3");  
}  

?>  

這個進行用戶檢查并將用戶引導到用戶郵件頁.

messages.php3  

<?php  

$mailserver="{localhost/imap}";  
$link=imap_open($mailserver,$php_auth_user,$php_auth_pw);  
$headers=imap_headers($link);  

for($x=1; $x < count($headers); $x++) {  
$idx=($x-1);  
echo "<a href="view.php3?num=$x">$headers[$idx]</a><br>";  
}  

?>  

通過驗證后連接到imap服務器$mailserver

然后在取得郵件列表,并創建閱讀郵件的連接

view.php3:  

<?php  

$mailserver="{localhost/imap}";  
$link=imap_open($mailserver,$php_auth_user,$php_auth_pw);  
$header=imap_header($link,$num);  

echo "from: $header[fromaddress]<br>";  
echo "to: $header[toaddress]<br>";  
echo "date: $header[date]<br>";  
echo "subject: $header[subject]<br><br>";  
echo imap_body($link,$num);  

?>  

view.php3打開imap連接并取得郵件頭部信息并顯示

這only是一個拿來完完的小程序,要完整的自己去寫啦!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昂仁县| 犍为县| 罗山县| 屏南县| 田东县| 宝丰县| 靖宇县| 莱芜市| 枣强县| 白银市| 合肥市| 孝昌县| 原阳县| 永嘉县| 怀仁县| 祁连县| 旬邑县| 天全县| 奉新县| 新巴尔虎右旗| 临邑县| 融水| 姚安县| 湄潭县| 东丰县| 竹溪县| 榆中县| 云林县| 周宁县| 东明县| 通城县| 德昌县| 区。| 观塘区| 宜君县| 府谷县| 滕州市| 丁青县| 闵行区| 广丰县| 湖口县|