First, the Phpmailer version used primarily by Ecmall is too low to support encrypted connections.
Then, you have to make some adjustments to the corresponding code.
1. Cover Phpmailer
Please download from the attachment:
Copy Code code as follows:
Http://cywl.jb51.net:81/201405/yuanma/ecmall_phpmailer_lib (jb51.net). zip
2. Transform Lib
Involving two lib:mail.lib.php, mail_quequ.lib.php
In the constructors of these two classes, add a parameter pass. such as Mailer
Copy Code code as follows:
function __construct ($from, $email, $protocol, $host = ', $port = ', $user = ', $pass = ', $SMTPSecure = false)//increase $SM Tpsecure
{
$this->mailer ($from, $email, $protocol, $host, $port, $user, $pass);
}
function Mailer ($from, $email, $protocol, $host = ', $port = ', $user = ', $pass = ', $SMTPSecure = False)
....
MailQueue in the same vein.
3. Encapsulation Call function
Global.lib.php about 300 lines
Add a row to the function &get_mailer ():
Copy Code code as follows:
$secure = Conf::get (' Email_ssl ')/Add this line
$mailer = new Mailer ($sender, $from, $protocol, $host, $port, $username, $password, $secure);
4. Adjust the background email settings interface, add the relevant settings
Background Template: setting.email_setting.html Add a configuration item
Copy Code code as follows:
<tr>
<th class= "paddingT15" > Mail server encryption Method:</th>
<TD class= "paddingT15 wordSpacing5" >
{Html_radios name= "Email_ssl" options= $email _ssl checked= $setting. Email_ssl}
<label class= "Field_notice" > This feature requires your PHP to support the OpenSSL module, if you want to use this feature, please contact your space provider to confirm support for this module </label>
</td>
</tr>
Also, modify the parameter pass of the message test
Copy Code code as follows:
<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 (); Add this line
$.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) {
if (Data.done) {
alert (data.msg);
}
else{
alert (data.msg);
}
},
Error:function () {alert (' {$lang. mail_send_failure} ');}
});
}
</script>
And then you need to modify the setting.app.php
Copy Code code as follows:
/**
* EMAIL Settings
*
* @author Hyber
* @return void
*/
function email_setting ()
{
$model _setting = &af (' Settings ');
$setting = $model _setting->getall (); Load System Setup Data
if (!is_post)
{
$this->assign (' setting ', $setting);
$this->assign (' Mail_type ', Array (
MAIL_PROTOCOL_SMTP => lang::get (' SMTP '),
Mail_protocol_local => lang::get (' email '),
));
Increase
$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 '];//increased
$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 ');
}
}
and test the message method.
Copy Code code as follows:
function Send_test_email ()
{
if (is_post)
{
$email _from = conf::get (' site_name ');
$email _type = $_post[' Email_type '];
$email _host = $_post[' email_host '];
$email _ssl = $_post[' Email_ssl '];//increased
$email _port = $_post[' Email_port '];
$email _addr = $_post[' email_addr '];
$email _id = $_post[' email_id '];
$email _pass = $_post[' Email_pass '];
$email _test = $_post[' email_test '];
$email _subject = lang::get (' Email_subjuect ');
$email _content = lang::get (' email_content ');
/* Use Mailer class * *
Import (' Mailer.lib ');
$mailer = new Mailer ($email _from, $email _addr, $email _type, $email _host, $email _port, $email _id, $email _pass, $email _ssl )//Increase
$mail _result = $mailer->send ($email _test, $email _subject, $email _content, CHARSET, 1);
if ($mail _result)
{
$this->json_result (', ' mail_send_succeed ');
}
Else
{
$this->json_error (' Mail_send_failure ', implode ("\ n", $mailer->errors));
}
}
Else
{
$this->show_warning (' Hacking attempt ');
}
}
The TLS method has not been tested.