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的乐活途购物分享社区php版源码.zip
共833个文件
gif:259个
php:197个
png:105个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 197 浏览量
2023-10-15
23:45:21
上传
评论
收藏 3.98MB ZIP 举报
温馨提示
基于PHP的乐活途购物分享社区php版源码.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP的乐活途购物分享社区php版源码.zip (833个子文件)
global.css 79KB
global老版本备份.css 59KB
forum.css 28KB
detail.css 24KB
index.css 23KB
detail2343243.css 21KB
profile08.css 20KB
topicdetail.css 18KB
default.css 16KB
goods.css 16KB
goods老版备份.css 14KB
detail老版本备份.css 14KB
setting.css 11KB
index老版本备份.css 10KB
base.css 7KB
style.css 6KB
style.css 5KB
jie.css 5KB
reglogin.css 3KB
main.css 1KB
file_manager.css 1KB
login.css 902B
editor.css 855B
topicEdit.css 563B
zhufu.gif 43KB
qq.gif 35KB
35.gif 13KB
42.gif 13KB
40.gif 10KB
18.gif 8KB
19.gif 8KB
wq_thumb.gif 8KB
11.gif 8KB
default.gif 8KB
gza_thumb.gif 8KB
32.gif 7KB
49.gif 6KB
loading.gif 6KB
29.gif 6KB
highlight.gif 6KB
bs2_thumb.gif 5KB
97.gif 5KB
65.gif 5KB
logo_1.gif 5KB
31.gif 5KB
46.gif 5KB
57.gif 5KB
phpmailer.gif 5KB
45.gif 5KB
8.gif 5KB
43.gif 4KB
33.gif 4KB
68.gif 4KB
crazya_thumb.gif 4KB
26.gif 4KB
14.gif 4KB
7.gif 4KB
51.gif 4KB
10.gif 4KB
47.gif 4KB
72.gif 4KB
6.gif 3KB
94.gif 3KB
84.gif 3KB
thinksns.gif 3KB
41.gif 3KB
17.gif 3KB
9.gif 3KB
wg_thumb.gif 3KB
28.gif 3KB
50.gif 3KB
laugh.gif 3KB
95.gif 3KB
22.gif 3KB
27.gif 3KB
money_thumb.gif 3KB
67.gif 3KB
90.gif 3KB
60.gif 3KB
58.gif 3KB
loginlogo.gif 2KB
edit_toolbar.gif 2KB
74.gif 2KB
25.gif 2KB
101.gif 2KB
sleepya_thumb.gif 2KB
54.gif 2KB
logo.gif 2KB
99.gif 2KB
24.gif 2KB
12.gif 2KB
guangNavi.gif 2KB
73.gif 2KB
sweata_thumb.gif 2KB
cry.gif 2KB
104.gif 2KB
103.gif 2KB
34.gif 2KB
88.gif 2KB
hsa_thumb.gif 2KB
共 833 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
易小侠
- 粉丝: 6481
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Typescript和PHP的编程知识储备库设计源码 - study-php
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
- 基于Vue和微信小程序的监理日志系统设计源码 - supervisionLog
- 基于Java和LCN分布式事务框架的设计源码 - tx-lcn
- 基于Java和JavaScript的茶叶评级管理系统设计源码 - tea
- IMG_5680.JPG
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功