imap是一款郵件交互訪問的協議了,下面我來給大家介紹利用php imap模塊來快速獲取郵件的例子,有興趣的朋友可參考一下,列出所有目錄,代碼如下:
- $host = '{imap.mail.yahoo.com:993/ssl}';
- $user = 'user@yahoo.com';
- $pass = 'password';
- $inbox = imap_open($host, $user, $pass);
- $mailboxes = imap_list($inbox, $host, '*');
- $mailboxes = str_replace($host, '', $mailboxes);
- print_r($mailboxes);
- //結果:
- Array
- (
- [0] => Bulk Mail
- [1] => Draft
- [2] => Inbox
- [3] => Sent
- [4] => Trash
- )
重新打開指定的目錄:
- imap_reopen($inbox, $host.'Bulk Mail');
- $emails = imap_search($inbox,'ALL');
- print_r($emails);
windows安裝imap
注意在windows中我們需要開啟php.ini中的一個imap模板了,在php中找到php_imap.dll擴展然后開啟,同時如果你看extensions沒有關php_imap.dll需要復制一個過去.
linux中安裝imap
最后完整的編譯 imap 模塊參數如下:
- ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-kerberos=/usr --with-imap-ssl=/usr
- make//開源軟件:Vevb.com
- make install
|
新聞熱點
疑難解答