First, the phpmailer version used by ecmall is too low and does not support encrypted connections.
Then, make some adjustments to the corresponding code.
1. Overwrite phpmailer
Download the attachment:
Copy codeThe Code is as follows:
Http://cywl.jb51.net: 81/201405/yuanma/ecmall_phpmailer_lib(jb51.netw..zip
2. Modify lib
Two lib involved: mail. lib. php and mail_quequ.lib.php
Add a parameter to the constructor of these two classes. For example, Mailer
Copy codeThe Code is as follows:
Function _ construct ($ from, $ email, $ protocol, $ host = '', $ port ='', $ user = '', $ pass = '', $ SMTPSecure = false) // Add $ SMTPSecure
{
$ This-> Mailer ($ from, $ email, $ protocol, $ host, $ port, $ user, $ pass, $ SMTPSecure );
}
Function Mailer ($ from, $ email, $ protocol, $ host = '', $ port ='', $ user = '', $ pass = '', $ SMTPSecure = false)
....
The same is true for MailQueue.
3. encapsulate the call Function
About 300 rows in global. lib. php
Add a row to function & get_mailer:
Copy codeThe Code is as follows:
$ Secure = Conf: get ('email _ ssl '); // Add this line
$ Mailer = new Mailer ($ sender, $ from, $ protocol, $ host, $ port, $ username, $ password, $ secure); // simultaneously PASS Parameters
4. Adjust the background email settings page and add related settings
Background template: setting.email_setting.html adds a configuration item
Copy codeThe Code is as follows:
<Tr>
<Th class = "paddingT15"> email 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 function requires your php to support the OpenSSL module. To use this function, contact your space provider to confirm that this module is supported. </label>
</Td>
</Tr>
At the same time, modify the mail test parameter transmission
Copy codeThe Code is 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>
You also need to modify setting. app. php
Copy codeThe Code is as follows:
/**
* EMAIL settings
*
* @ Author Hyber
* @ Return void
*/
Function email_setting ()
{
$ Model_setting = & af ('settings ');
$ Setting = $ model_setting-> getAll (); // load the system setting 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 '),
));
// Add
$ 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']; // Add
$ 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 mail method.
Copy codeThe Code is 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 ']; // Add
$ 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 the mailer class */
Import ('mailer. lib ');
$ Mailer = new Mailer ($ email_from, $ email_addr, $ email_type, $ email_host, $ email_port, $ email_id, $ email_pass, $ email_ssl); // Add
$ 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.