php imap收郵件原始碼 zp blog

2021-10-22 21:59:05 字數 2438 閱讀 1617

前段時間一直在研究郵件獲取和內容的提取,具體例項就是比如在阿里購物後,當商家發貨後會收到乙份已發貨郵件,郵件裡會包含訂單號和運單號(要的就是這個 嘿嘿),至於幹嘛用,在這就不多說明了

這邊用的方法是imap不是pop3,網上有很多pop3的郵件接收類,我開始也嘗試用這個類,但當郵箱郵件比較多時,執行會很慢,動不動還會超時。imap好像預設只接收最近幾百份郵件,不會全部遍歷整個郵箱郵件。對我來說這樣挺好。

date_default_timezone_set("asia/shanghai");

$mailserver="imap.126.com"; //imap主機

$mailuser = '******@126.com'; //郵箱使用者名稱

$mailpass = '********'; //郵箱密碼

$mbox = imap_open($maillink,$mailuser,$mailpass); //開啟信箱imap_open

$totalrows = imap_num_msg($mbox); //取得信件數

for ($i=$totalrows;$i>$totalrows-50;$i--))\s+/isx',$mailbody,$odnum);   //提取訂單號運單號

echo $odnum[1][0];

echo "

\r\n";

echo $odnum[1][1];

echo "

---------------------- 

\r\n";

imap_close($mbox);

echo date("y-m-d h:i:s");

imap_base64:    解 base64 編碼。

imap_body:    讀信的內文。

imap_check:    返回郵箱資訊。

imap_close:    關閉 imap 鏈結。

imap_createmailbox:    建立新的信箱。

imap_delete:    標記欲刪除郵件。

imap_deletemailbox:    刪除既有信箱。

imap_expunge:    刪除已標記的郵件。

imap_fetchbody:    從信件內文取出指定部分。

imap_fetchstructure:    獲取某信件的結構資訊。

imap_header:    獲取某信件的標頭資訊。

imap_headers:    獲取全部信件的標頭資訊。

imap_listmailbox:    獲取郵箱列示。

imap_listsubscribed:    獲取訂閱郵箱列示。

imap_mail_copy:    複製指定信件到它處郵箱。

imap_mail_move:    移動指定信件到它處郵箱。

imap_num_msg:    取得信件數。

imap_num_recent:    取得新進信件數。

imap_open:    開啟 imap 鏈結。

imap_ping:    檢查 imap 是否連線。

imap_renamemailbox:    更改郵箱名字。

imap_reopen:    重開 imap 鏈結。

imap_subscribe:    訂閱郵箱。

imap_undelete:    取消刪除郵件標記。

imap_unsubscribe:    取消訂閱郵箱。

imap_qprint:    將 qp 編碼轉成八位。

imap_8bit:    將八位轉成 qp 編碼。

imap_binary:    將八位轉成 base64 編碼。

imap_scanmailbox:    尋找信件有無特定字串。

imap_mailboxmsginfo:    取得目前郵箱的資訊。

imap_rfc822_write_address:    電子郵件位址標準化。

imap_rfc822_parse_adrlist:    解析電子郵件位址。

imap_setflag_full:    配置信件標誌。

imap_clearflag_full:    清除信件標誌。

imap_sort:    將信件標頭排序。

imap_fetchheader:    取得原始標頭。

imap_uid:    取得信件 uid。

imap_getmailboxes:    取得全部信件詳細資訊。

imap_getsubscribed:    列出所有訂閱郵箱。

imap_msgno:    列出 uid 的連續信件。

imap_search:    搜尋指定標準的信件。

imap_last_error:    最後的錯誤資訊。

imap_errors:    所有的錯誤資訊。

imap_alerts:    所有的警告資訊。

imap_status:    目前的狀態資訊。

DevExpress 14 2 3原始碼編譯 z

devexpress.xpf.demobase.sl.csproj和 devexpress.xpf.demobase.design.sl.csproj無法編譯 解決辦法 用vs2010 管理員模式 按順序分別開啟 devexpress.xpf.demobase.web.csproj devexpre...

C 中非同步傳送郵件原始碼

在學習閒暇時間,將寫內容過程經常用的內容段做個收藏,下面的內容是關於c 中非同步傳送郵件的內容,應該能對各位朋友有好處。mailmessage m new mailmessage this is the subject for the authorized email.this is the bod...

php郵件中繼原始碼 PHP實現郵件群發的原始碼

複製 如下 請求 phpmailer類 檔案 require once class.phpmailer.php 傳送email函式 function smtp mail sendto email,subject,body,extra hdrs,user name 封 郵件.smtp mail lis...