opencart安装和使用PHPMailer
一、安装PHPMailer
1)先给opencart项目安装vqmod
- 下载最新版本: http://code.google.com/p/vqmod (目前最新版本是vqmod-2.5.1-standard)
- 把解压出来的文件放到opencart根目录下
- 执行 http://www.yoursite.com/vqmod/install
- 你能看到成功信息“VQMOD ALREADY INSTALLED!”. 如果没有,就检查3,4步
2)下载PHPMailerV2.1.zip
把PHPMailerV2.1.zip解压出来的文件夹 upload下的文件:
system/library/phpmailer
vqmod/xml/PHPMailerV2.xml
分别放到opencart项目对应的目录下:
system/library/
vqmod/xml/
二、修复PHPMailerV2.1.zip的PHPMailerV2.xml的2个bug,不知道为啥开发改插件的人没发现
1)PHPMailerV2.xml文件中添加的send()函数,编译生成会导致多出一个'}',去掉126行的'}';
2)xml中的host_name,port,username,password跟opencart项目的变量不对应,应该改成smtp_hostname,smtp_port,smtp_username,smtp_password;
旧xml
<modification> <id>PHPMailer</id>
<version>2.0</version>
<vqmver>1.0.4</vqmver>
<author>SpotOnSolutions.net</author> <file name="system/library/mail.php">
<operation>
<search position="before"><![CDATA[
class Mail
]]></search>
<add><![CDATA[include_once(DIR_SYSTEM . 'library/phpmailer/class.phpmailer.php');]]></add>
</operation> <operation>
<search position="before"><![CDATA[
protected $subject;
]]></search>
<add><![CDATA[ protected $readreceipt;]]></add>
</operation> <operation>
<search position="before"><![CDATA[
public function setSubject
]]></search>
<add><![CDATA[ public function setReadReceipt($readreceipt) {
$this->readreceipt = $readreceipt;
}
]]></add>
</operation> <operation>
<search position="before"><![CDATA[public function send() {]]></search>
<add><![CDATA[/*]]></add>
</operation> <operation>
<search position="bottom" offset="2"><![CDATA[
public function send() {
]]></search>
<add><![CDATA[*/
public function send() {
if (!$this->to) {
trigger_error('Error: E-Mail to required!');
exit();
} if (!$this->from) {
trigger_error('Error: E-Mail from required!');
exit();
} if (!$this->sender) {
trigger_error('Error: E-Mail sender required!');
exit();
} if (!$this->subject) {
trigger_error('Error: E-Mail subject required!');
exit();
} if ((!$this->text) && (!$this->html)) {
trigger_error('Error: E-Mail message required!');
exit();
} $mail = new PHPMailer();
$mail->CharSet = "UTF-8"; if (is_array($this->to)) {
foreach ($this->to as $toTmp){
$mail->AddAddress($toTmp);
}
} else {
$mail->AddAddress($this->to);
} if(!empty($this->readreceipt)) {
$mail->ConfirmReadingTo = $this->readreceipt;
} $mail->Subject = $this->subject; $mail->AddReplyTo($this->from, $this->sender);
$mail->SetFrom($this->from, $this->sender);
$mail->AddReplyTo($this->from, $this->sender); if (!$this->html) {
$mail->Body = $this->text;
} else {
$mail->MsgHTML($this->html);
if ($this->text) {
$mail->AltBody = $this->text;
} else {
$mail->AltBody = 'This is a HTML email and your email client software does not support HTML email!';
}
} foreach ($this->attachments as $attachment) {
if (file_exists($attachment['file'])) {
$mail->AddAttachment($attachment['file']);
}
} if ($this->protocol == 'smtp') {
$mail->IsSMTP();
$mail->Host = $this->hostname;
$mail->Port = $this->port;
if($this->port == '587'){
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
} elseif ($this->port == '465') {
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
}
if (!empty($this->username) && !empty($this->password)) {
$mail->SMTPAuth = true;
$mail->Host = $this->hostname;
$mail->Username = $this->username;
$mail->Password = $this->password;
}
}
$mail->Send();
}
]]></add>
</operation> </file> </modification>
修复后的xml:
<modification> <id>PHPMailer</id>
<version>2.0</version>
<vqmver>1.0.4</vqmver>
<author>SpotOnSolutions.net</author> <file name="system/library/mail.php">
<operation>
<search position="before"><![CDATA[
class Mail
]]></search>
<add><![CDATA[include_once(DIR_SYSTEM . 'library/phpmailer/class.phpmailer.php');]]></add>
</operation> <operation>
<search position="before"><![CDATA[
protected $subject;
]]></search>
<add><![CDATA[ protected $readreceipt;]]></add>
</operation> <operation>
<search position="before"><![CDATA[
public function setSubject
]]></search>
<add><![CDATA[ public function setReadReceipt($readreceipt) {
$this->readreceipt = $readreceipt;
}
]]></add>
</operation> <operation>
<search position="before"><![CDATA[public function send() {]]></search>
<add><![CDATA[/*]]></add>
</operation> <operation>
<search position="bottom" offset="2"><![CDATA[
public function send() {
]]></search>
<add><![CDATA[*/
public function send() {
if (!$this->to) {
trigger_error('Error: E-Mail to required!');
exit();
} if (!$this->from) {
trigger_error('Error: E-Mail from required!');
exit();
} if (!$this->sender) {
trigger_error('Error: E-Mail sender required!');
exit();
} if (!$this->subject) {
trigger_error('Error: E-Mail subject required!');
exit();
} if ((!$this->text) && (!$this->html)) {
trigger_error('Error: E-Mail message required!');
exit();
} $mail = new PHPMailer();
$mail->CharSet = "UTF-8"; if (is_array($this->to)) {
foreach ($this->to as $toTmp){
$mail->AddAddress($toTmp);
}
} else {
$mail->AddAddress($this->to);
} if(!empty($this->readreceipt)) {
$mail->ConfirmReadingTo = $this->readreceipt;
} $mail->Subject = $this->subject; $mail->AddReplyTo($this->from, $this->sender);
$mail->SetFrom($this->from, $this->sender);
$mail->AddReplyTo($this->from, $this->sender); if (!$this->html) {
$mail->Body = $this->text;
} else {
$mail->MsgHTML($this->html);
if ($this->text) {
$mail->AltBody = $this->text;
} else {
$mail->AltBody = 'This is a HTML email and your email client software does not support HTML email!';
}
} foreach ($this->attachments as $attachment) {
if (file_exists($attachment['file'])) {
$mail->AddAttachment($attachment['file']);
}
} if ($this->protocol == 'smtp') {
$mail->IsSMTP();
$mail->Host = $this->smtp_hostname;
$mail->Port = $this->smtp_port;
if($this->smtp_port == '587'){
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
} elseif ($this->smtp_port == '465') {
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
}
if (!empty($this->smtp_username) && !empty($this->smtp_password)) {
$mail->SMTPAuth = true;
$mail->Host = $this->smtp_hostname;
$mail->Username = $this->smtp_username;
$mail->Password = $this->smtp_password;
}
}
$mail->Send();
]]></add>
</operation> </file> </modification>
三、配置opencart后台的mail设置
系统设置->网店设置->编辑
协议选择SMTP,我使用的是smtp.126.com,用户名是你的邮箱 xxx@126.com。注意:你的邮箱必须是开通了smtp权限的才可以
最重要的一点:常规 设置里的E-Mail必须填写成跟 邮件 上面的用户的邮箱一致,因为opencart发邮件所使用的是 常规 设置里的E-Mail
到此完毕!
opencart安装和使用PHPMailer的更多相关文章
- opencart 安装
1:安装 php5 apache2 mysql 2:下载opencart wget https://github.com/opencart/opencart/archive/master.zi ...
- 在Linux CentOS6系统中安装开源CMS程序OpenCart的教程
OpenCart是一个开放源码的店面,旨在为您提供灵活和细粒度的在线店面管理.在开始之前,您应该已经在您的Linode上设置了一个LAMP堆栈.您还应该设置主机名. PHP设置 为了使用OpenCar ...
- OpenCart本地调试环境搭建
OpenCart简介: 免费开源网络版电子商务系统,是建立在线商务网站首选之一.有众多用户和开发基础,结合其丰富特性与模板插件,可最大化定制在线商店.(也就是用来方便开网店的) 本地调试准备: Fir ...
- 修改opencart extension插件代码后无法重新安装的解决办法
有时我们在为opencart安装一些插件后,发现有些地方需要细微的调整,然后去修改插件代码重新安装,但是却没有成功.开始有点怀疑是不是不能修改代码,但也不至于啊,不然开发者怎么制作插件.应该是哪里出了 ...
- 使用PHP利用phpmailer发送电子邮件
先来几句废话: phpMailer是一个非常强大的php发送邮件类,可以设定发送邮件地址.回复地址.邮件主题.html网页,上传附件,并且使用起来非常方便. phpMailer的特点: ...
- tp 5 实现邮件发送
参考博客: https://www.cnblogs.com/ccdr/p/14751548.htmlhttps://www.cnblogs.com/ccdr/p/14751548.html 1:qq邮 ...
- opencart在空间中安装出错,连接不上mysql
客户要求,要在国外某空间安装opencart.话说opencart根本没怎么搞过,也不太清楚,php也是半吊子,临时看了几天,硬着头皮上把. 出错,安装进行到数据库连接设置的时候,死活连接不上,开始以 ...
- OpenCart 如何安装 vQmod 教程
vQmod (全称 Virtual Quick Mod),是 OpenCart (PHP 开源电商网站系统)上一个可以以虚拟方式修改原文件内容而设计的一个插件系统.它的使用很简单,我们先用 xml 的 ...
- 用composer安装php代码(以安装phpmailer为例)
1.安装composer.exe软件 2.下载composer.phar 3.创建composer.json文件 { "require": { "php": & ...
随机推荐
- Java基础-封装(09)
通过对象直接访问成员变量,会存在数据安全问题(比如年龄不能为负).这个时候,我们就不能让外界的对象直接访问成员变量. private关键字 是一个权限修饰符.可以修饰成员(成员变量和成员方法)被pri ...
- Leha and another game about graph CodeForces - 840B (dfs)
链接 大意: 给定无向连通图, 每个点有权值$d_i$($-1\leq d_i \leq 1$), 求选择一个边的集合, 使得删除边集外的所有边后, $d_i$不为-1的点的度数模2等于权值 首先要注 ...
- 『Sklearn』数据划分方法
原理介绍 K折交叉验证: KFold,GroupKFold,StratifiedKFold, 留一法: LeaveOneGroupOut,LeavePGroupsOut,LeaveOneOut,Lea ...
- python-day36--并发编程之多线程
十三.死锁.递归锁 1.所谓死锁: 是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永 ...
- MFC中format函数用法
本文转载于:http://blog.csdn.net/sunxc123/article/details/7742982 在MFC程序中,使用CString来处理字符串是一个很不错的选择.CString ...
- EBS标准的查看供应商地址
--获取供应商PARTY_ID SELECT * FROM HZ_PARTIES HP WHERE HP.PARTY_NAME='XXXXXX' VO数据源:oracle.apps.pos.suppl ...
- Freemaker FTL指令常用标签及语法
https://blog.csdn.net/pengpengpeng85/article/details/52070602 FTL指令常用标签及语法 注意:使用freemaker,要求所有标签必须闭合 ...
- HDU 2891
DESCRIPTION: 大意是说 先给你n个 同学的 上课时间.一周的第几天,开始和结束的时间点.然后对应q个出去玩的时间.要你给出谁不能出去.如果都能出去就输出none. 开始做的时候觉得每个同学 ...
- Allow Zero Length 允许空字符串 ACCESS
http://www.360doc.com/content/11/0118/20/991597_87447868.shtml https://microsoft.public.data.ado.nar ...
- 三个安装,手机看VIP电影。写给亲爱的学习
三个安装,看VIP电影. 市场安装firefox 安装Tempermonkey 打开firefox,点击右上角的三个点,点击附加组件 继续点击浏览全部firefox附加组件 在上面的搜索框输入 tam ...