这篇文章主要介绍了ECMall支持SSL连接邮件服务器的配置方法详解
首先,主要是ecmall使用的phpmailer版本太低,,不支持加密连接。
然后,得对相应代码做一定调整。
1. 覆盖phpmailer
请从附件进行下载:
复制代码 代码如下:
:81/201405/yuanma/ecmall_phpmailer_lib(jb51.net).zip
2. 改造lib
涉及到两个lib:mail.lib.php 、mail_quequ.lib.php
在这两个类的构造函数中,增加一个参数传递。如Mailer
复制代码 代码如下:
function __construct($from, $email, $protocol, $host = '', $port = '', $user = '', $pass = '', $SMTPSecure = false)//增加$SMTPSecure
{
$this->Mailer($from, $email, $protocol, $host, $port, $user, $pass, $SMTPSecure);
}
function Mailer($from, $email, $protocol, $host = '', $port = '', $user = '', $pass = '', $SMTPSecure = false)
....
MailQueue中同理。
3. 封装调用函数
global.lib.php 约300行
function &get_mailer()中增加一行:
复制代码 代码如下:
$secure = Conf::get('email_ssl');//增加这一行
$mailer = new Mailer($sender, $from, $protocol, $host, $port, $username, $password, $secure);//同时传递参数
4. 调整后台email设置界面,增加相关设置项
后台模板:setting.email_setting.html 增加一个配置项
复制代码 代码如下:
同时,修改邮件测试的参数传递
复制代码 代码如下:
然后还需要修改setting.app.php
复制代码 代码如下:
/**
* EMAIL 设置
*
* @author Hyber
* @return void
*/
function email_setting()
{
$model_setting = &af('settings');
$setting = $model_setting->getAll(); //载入系统设置数据
if (!IS_POST)
{
$this->assign('setting', $setting);
$this->assign('mail_type', array(
MAIL_PROTOCOL_SMTP => Lang::get('smtp'),
MAIL_PROTOCOL_LOCAL => Lang::get('email'),
));
//增加
$this->assign('email_ssl', array(
=> Lang::get('no'),
=> 'SSL',
=> 'TLS',
));
$this->display('setting.email_setting.html');
}
else
{
$data['email_type'] = $_POST['email_type'];
$data['email_host'] = $_POST['email_host'];
$data['email_ssl'] = $_POST['email_ssl'];//增加
$data['email_port'] = $_POST['email_port'];
$data['email_addr'] = $_POST['email_addr'];
$data['email_id'] = $_POST['email_id'];
$data['email_pass'] = $_POST['email_pass'];
$data['email_test'] = $_POST['email_test'];
$model_setting->setAll($data);
$this->show_message('edit_email_setting_successed');
}
}
以及测试邮件方法。
复制代码 代码如下: