This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented.
With that noted, here is how to implement it:
Install the class file
I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory:
[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi]
When you need it, create your POP3 object
Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer:
[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi]
The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier.
The Parameters
The Authorise parameters are as follows:
[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi]
1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address)
2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host)
3. 30 - A connection time-out value (in seconds)
4. mailer - The POP3 Username required to logon
5. password - The POP3 Password required to logon
6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser)
Final Comments + the Download
1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me.
2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time.
3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead.
4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with.
Download
Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself.
My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class)
没有合适的资源?快使用搜索试试~ 我知道了~
php电子邮件服务器搭建
共65个文件
php:47个
html:5个
txt:5个
2星 需积分: 34 38 下载量 24 浏览量
2016-09-07
13:00:54
上传
评论 3
收藏 210KB ZIP 举报
温馨提示
在php环境中建立phpmail专业类,快速搭建php邮件服务器,相当方便!
资源推荐
资源详情
资源评论
收起资源包目录
phpmailer.zip (65个子文件)
phpmailer
index.php 728B
docs
extending.html 4KB
Callback_function_notes.txt 616B
use_gmail.txt 1KB
DomainKeys_notes.txt 2KB
pop3_article.txt 4KB
Note_for_SMTP_debugging.txt 1KB
faq.html 3KB
class.phpmailer.php 73KB
test
testemail.php 1KB
contents.html 253B
phpmailerTest.php 23KB
test_callback.php 3KB
test.png 1KB
js
datagrid-detailview.js 12KB
jquery.edatagrid.js 11KB
jquery-1.6.min.js 88KB
jquery.easyui.min.js 345KB
easyui-lang-zh_CN.js 2KB
class.smtp.php 25KB
try.php 316B
Untitled-3.php 364B
class.pop3.php 10KB
examples
test_pop_before_smtp_advanced.php 1KB
images
phpmailer.gif 5KB
phpmailer_mini.gif 1KB
test_db_smtp_basic.php 2KB
test_smtp_advanced.php 2KB
test_smtp_gmail_basic.php 2KB
index.html 3KB
test_smtp_basic_no_auth.php 2KB
test_smtp_gmail_advanced.php 2KB
test_mail_advanced.php 1KB
contents.html 805B
test_smtp_advanced_no_auth.php 1KB
test_sendmail_basic.php 1KB
test_pop_before_smtp_basic.php 1KB
test_smtp_basic.php 2KB
test_sendmail_advanced.php 1KB
test_mail_basic.php 1KB
test.php 2KB
language
phpmailer.lang-cz.php 2KB
phpmailer.lang-tr.php 2KB
phpmailer.lang-nl.php 2KB
phpmailer.lang-ar.php 2KB
phpmailer.lang-ru.php 2KB
phpmailer.lang-ro.php 2KB
phpmailer.lang-es.php 2KB
phpmailer.lang-fr.php 2KB
phpmailer.lang-hu.php 2KB
phpmailer.lang-pl.php 2KB
phpmailer.lang-se.php 2KB
phpmailer.lang-no.php 1KB
phpmailer.lang-ca.php 2KB
phpmailer.lang-dk.php 2KB
phpmailer.lang-zh_cn.php 1KB
phpmailer.lang-zh.php 1KB
phpmailer.lang-it.php 2KB
phpmailer.lang-et.php 2KB
phpmailer.lang-fi.php 2KB
phpmailer.lang-de.php 2KB
phpmailer.lang-ch.php 1KB
phpmailer.lang-fo.php 2KB
phpmailer.lang-br.php 2KB
phpmailer.lang-ja.php 2KB
共 65 条
- 1
资源评论
- yaya2le20132017-10-06再下载下看看
- okiss02017-06-20正在看,感觉还行。
- louniao09342018-10-07介绍hMailServer,不是很实用
lwb197651
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 高等数学第一章第二节数列的极限
- Python 版冒泡排序算法源代码
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功