首先,主要是ecmall使用的phpmailer版本太低,不支持加密连接。
然后,得对相应代码做一定调整。
1. 覆盖phpmailer
请从附件进行下载:
代码如下:
http://cywl.Vevb.com:81/201405/yuanma/ecmall_phpmailer_lib(Vevb.com).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 增加一个配置项
代码如下:
<tr>
<th class="paddingT15">邮件服务器加密方式:</th>
<td class="paddingT15 wordSpacing5">
{html_radios name="email_ssl" options=$email_ssl checked=$setting.email_ssl}
<label class="field_notice">此功能要求您的php必须支持OpenSSL模块, 如果您要使用此功能,请联系您的空间商确认支持此模块</label>
</td>
</tr>
同时,修改邮件测试的参数传递
代码如下:
<script type="text/javascript">
$(function(){
$('#send_test_email').click(send_test_email);
});
function send_test_email(){
var email_type = $('input[name="email_type"]:checked').val();
var email_ssl = $('input[name="email_ssl"]:checked').val();//增加这一行
$.ajax({
type:"POST",
url:"index.php",
data:'app=setting&act=send_test_email&email_type='+email_type+'&email_host='+$("#email_host").val()+'&email_port='+$("#email_port").val()+'&email_addr='+$("#email_addr").val()+'&email_id='+$("#email_id").val()+'&email_pass='+$("#email_pass").val()+'&email_test='+$("#email_test").val()+'&email_ssl='+email_ssl,
dataType:"json",
success:function(data){
新闻热点
疑难解答