In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to configure ECMall to support SSL to connect to the mail server". Many people will encounter this dilemma in the operation of the actual case, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
First of all, the main reason is that the phpmailer version used by ecmall is too low to support encrypted connections.
Then you have to make some adjustments to the corresponding code.
1. Override phpmailer
The copy code is as follows:
Http://cywl.jb51.net:81/201405/yuanma/ecmall_phpmailer_lib(jb51.net).zip
two。 Revamping lib
Two lib:mail.lib.php and mail_quequ.lib.php are involved
In the constructor of these two classes, add a parameter pass. Such as Mailer
The copy 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 in MailQueue.
3. Encapsulate the calling function
Global.lib.php is about 300 lines
Add a line to function & get_mailer ():
The copy code is as follows:
$secure = Conf::get ('email_ssl'); / / add this line
$mailer = new Mailer ($sender, $from, $protocol, $host, $port, $username, $password, $secure); / / pass parameters simultaneously
4. Adjust the background email settings interface and add related setting items
Background template: setting.email_setting.html adds a configuration item
The copy code is as follows:
Encryption method of mail server:
{html_radios name= "email_ssl" options=$email_ssl checked=$setting.email_ssl}
This feature requires that your php must support the OpenSSL module. If you want to use this feature, please contact your space provider to confirm that it supports this module.
At the same time, modify the parameter delivery of the mail test
The copy code is as follows:
$(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}');}
});
}
Then you need to modify the setting.app.php.
The copy code is 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']; / / 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 testing email methods.
The copy 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 approach has not been tested.
This is the end of the content of "how to configure ECMall to support SSL connection to the mail server". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.