PHP obtains email instances based on imap, imap obtains instances
The example in this article describes how PHP obtains emails based on imap. Share it with everyone for your reference. The specific implementation method is as follows:
imap is a protocol for interactive email access. The following is an example that mainly uses the php imap module to quickly obtain emails and list all directories. The code is as follows:
Copy code The code is as follows:
$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);
//Result:
Array
(
[0] => Bulk Mail
[1] => Draft
[2] => Inbox
[3] => Sent
[4] => Trash
)
Reopen the specified directory:
Copy code The code is as follows:
imap_reopen($inbox, $host.'Bulk Mail');
$emails = imap_search($inbox,'ALL');
print_r($emails);
Supplement:
1. Windows installation imap
Note that in Windows we need to open an imap template in php.ini. Find the php_imap.dll extension in php and open it. At the same time, if you see that extensions are not connected, php_imap.dll needs to be copied.
2. Install imap in linux
The final complete compiled imap module parameters are as follows:
Copy the code The code is as follows:
./configure --with-php-config=/usr/local/webserver/php/bin/php- config --with-kerberos=/usr --with-imap-ssl=/usr
make
make install
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/909336.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/909336.htmlTechArticlePHP obtains email examples based on imap, imap obtains examples. This example describes how PHP obtains emails based on imap. Share it with everyone for your reference. The specific implementation method is as follows: imap is a...