PhpMail-SMTP-POP3-IMAP 邮件接收发送 Mail receiving and sending
最近遇到一个工程需要自动发件(SMTP)收件(IMAP/POP3)功能,发现很难找到一个PHP的完整包来使用
所以自己综合phpMailer,PhpImap,csdn博客等各开源代码,做一个收发件都包括的库,供新人使用。
有不足之处请指出
imap 收件示例require_once __DIR__ . '/src/__autoload.php';
set_time_limit(0);
//IMAP收件
//argument is the directory into which attachments are to be saved:
$mailbox = new \src\PhpImap\Mailbox('{imap.qq.com:993/imap/ssl}INBOX', '[email protected]', 'XXXXXXX', __DIR__);
//读取所有邮件id到数组:
//Read all messaged into an array:
$mailsIds = $mailbox->searchMailbox('ALL');
if (!$mailsIds) {
die('Mailbox is empty');
}
// Get the first message and save its attachment(s) to disk:
//获取一份邮件对象 打印出来
$mail = $mailbox->getMail($mailsIds[0]);
va