ECMall如何支持SSL连接邮件服务器的配置
首先,主要是ecmall使用的phpmailer版本太低,不支持加密连接。
然后,得对相应代码做一定调整。
1. 覆盖phpmailer
请从附件进行下载:
http://files.cnblogs.com/x3d/ecmall_phpmailer_lib.zip
2. 改造lib
涉及到两个lib:mail.lib.php 、mail_quequ.lib.php
在这两个类的构造函数中,增加一个参数传递。如Mailer
<span>function</span> __construct(<span>$from</span>, <span>$email</span>, <span>$protocol</span>, <span>$host</span> = '', <span>$port</span> = '', <span>$user</span> = '', <span>$pass</span> = '', <span>$SMTPSecure</span> = <span>false</span><span>)//增加<span>$SMTPSecure</span> { </span><span>$this</span>->Mailer(<span>$from</span>, <span>$email</span>, <span>$protocol</span>, <span>$host</span>, <span>$port</span>, <span>$user</span>, <span>$pass</span>, <span>$SMTPSecure</span><span>); } </span><span>function</span> Mailer(<span>$from</span>, <span>$email</span>, <span>$protocol</span>, <span>$host</span> = '', <span>$port</span> = '', <span>$user</span> = '', <span>$pass</span> = '', <span>$SMTPSecure</span> = <span>false</span><span>) </span>....
MailQueue中同理。
3. 封装调用函数
global.lib.php 约300行
function &get_mailer()中增加一行:
<span>$secure</span> = Conf::get('email_ssl'<span>);//增加这一行 </span><span>$mailer</span> = <span>new</span> Mailer(<span>$sender</span>, <span>$from</span>, <span>$protocol</span>, <span>$host</span>, <span>$port</span>, <span>$username</span>, <span>$password</span>, <span>$secure</span>);//同时传递参数
4. 调整后台email设置界面,增加相关设置项
后台模板:setting.email_setting.html 增加一个配置项
<span><</span><span>tr</span><span>></span> <span><</span><span>th </span><span>class</span><span>="paddingT15"</span><span>></span><span> 邮件服务器加密方式:</span><span></</span><span>th</span><span>></span> <span><</span><span>td </span><span>class</span><span>="paddingT15 wordSpacing5"</span><span>></span><span> {html_radios name="email_ssl" options=$email_ssl checked=$setting.email_ssl} </span><span><</span><span>label </span><span>class</span><span>="field_notice"</span><span>></span>此功能要求您的php必须支持OpenSSL模块, 如果您要使用此功能,请联系您的空间商确认支持此模块<span></</span><span>label</span><span>></span> <span></</span><span>td</span><span>></span> <span></</span><span>tr</span><span>></span>
同时,修改邮件测试的参数传递
<span><</span><span>script </span><span>type</span><span>="text/javascript"</span><span>></span><span> $(</span><span>function</span><span>(){ $(</span><span>'</span><span>#send_test_email</span><span>'</span><span>).click(send_test_email); }); </span><span>function</span><span> send_test_email(){ </span><span>var</span><span> email_type </span><span>=</span><span> $(</span><span>'</span><span>input[name="email_type"]:checked</span><span>'</span><span>).val(); </span><span>var</span><span> email_ssl </span><span>=</span><span> $(</span><span>'</span><span>input[name="email_ssl"]:checked</span><span>'</span><span>).val();//增加这一行 $.ajax({ type:</span><span>"</span><span>POST</span><span>"</span><span>, url:</span><span>"</span><span>index.php</span><span>"</span><span>, data:</span><span>'</span><span>app=setting&act=send_test_email&email_type=</span><span>'</span><span>+</span><span>email_type</span><span>+</span><span>'</span><span>&email_host=</span><span>'</span><span>+</span><span>$(</span><span>"</span><span>#email_host</span><span>"</span><span>).val()</span><span>+</span><span>'</span><span>&email_port=</span><span>'</span><span>+</span><span>$(</span><span>"</span><span>#email_port</span><span>"</span><span>).val()</span><span>+</span><span>'</span><span>&email_addr=</span><span>'</span><span>+</span><span>$(</span><span>"</span><span>#email_addr</span><span>"</span><span>).val()</span><span>+</span><span>'</span><span>&email_id=</span><span>'</span><span>+</span><span>$(</span><span>"</span><span>#email_id</span><span>"</span><span>).val()</span><span>+</span><span>'</span><span>&email_pass=</span><span>'</span><span>+</span><span>$(</span><span>"</span><span>#email_pass</span><span>"</span><span>).val()</span><span>+</span><span>'</span><span>&email_test=</span><span>'</span><span>+</span><span>$(</span><span>"</span><span>#email_test</span><span>"</span><span>).val()</span><span>+</span><span>'</span><span>&email_ssl=</span><span>'</span><span>+</span><span>email_ssl, dataType:</span><span>"</span><span>json</span><span>"</span><span>, success:</span><span>function</span><span>(data){ </span><span>if</span><span>(data.done){ alert(data.msg); } </span><span>else</span><span>{ alert(data.msg); } }, error: </span><span>function</span><span>(){alert(</span><span>'</span><span>{$lang.mail_send_failure}</span><span>'</span><span>);} }); } </span><span></</span><span>script</span><span>></span>
然后还需要修改setting.app.php
<span>/*</span><span>* * EMAIL 设置 * * @author Hyber * @return void </span><span>*/</span> <span>function</span><span> email_setting() { </span><span>$model_setting</span> = &af('settings'<span>); </span><span>$setting</span> = <span>$model_setting</span>->getAll(); <span>//</span><span>载入系统设置数据</span> <span>if</span> (!<span>IS_POST) { </span><span>$this</span>->assign('setting', <span>$setting</span><span>); </span><span>$this</span>->assign('mail_type', <span>array</span><span>( MAIL_PROTOCOL_SMTP </span>=> Lang::get('smtp'),<span> MAIL_PROTOCOL_LOCAL </span>=> Lang::get('email'),<span> ));<br /> <span>//增加 </span></span><span>$this</span>->assign('email_ssl', <span>array</span><span>( </span>0 => Lang::get('no'), 1 => 'SSL', 2 => 'TLS',<span> )); </span><span>$this</span>->display('setting.email_setting.html'<span>); } </span><span>else</span><span> { </span><span>$data</span>['email_type'] = <span>$_POST</span>['email_type'<span>]; </span><span>$data</span>['email_host'] = <span>$_POST</span>['email_host'<span>]; </span><span>$data</span>['email_ssl'] = <span>$_POST</span>['email_ssl'<span>];<span>//增加 </span></span><span>$data</span>['email_port'] = <span>$_POST</span>['email_port'<span>]; </span><span>$data</span>['email_addr'] = <span>$_POST</span>['email_addr'<span>]; </span><span>$data</span>['email_id'] = <span>$_POST</span>['email_id'<span>]; </span><span>$data</span>['email_pass'] = <span>$_POST</span>['email_pass'<span>]; </span><span>$data</span>['email_test'] = <span>$_POST</span>['email_test'<span>]; </span><span>$model_setting</span>->setAll(<span>$data</span><span>); </span><span>$this</span>->show_message('edit_email_setting_successed'<span>); } }</span>
以及测试邮件方法。
<span>function</span><span> send_test_email() { </span><span>if</span><span> (IS_POST) { </span><span>$email_from</span> = Conf::get('site_name'<span>); </span><span>$email_type</span> = <span>$_POST</span>['email_type'<span>]; </span><span>$email_host</span> = <span>$_POST</span>['email_host'<span>]; </span><span>$email_ssl</span> = <span>$_POST</span>['email_ssl'<span>];<span>//增加 </span></span><span>$email_port</span> = <span>$_POST</span>['email_port'<span>]; </span><span>$email_addr</span> = <span>$_POST</span>['email_addr'<span>]; </span><span>$email_id</span> = <span>$_POST</span>['email_id'<span>]; </span><span>$email_pass</span> = <span>$_POST</span>['email_pass'<span>]; </span><span>$email_test</span> = <span>$_POST</span>['email_test'<span>]; </span><span>$email_subject</span> = Lang::get('email_subjuect'<span>); </span><span>$email_content</span> = Lang::get('email_content'<span>); </span><span>/*</span><span> 使用mailer类 </span><span>*/</span><span> import(</span>'mailer.lib'<span>); </span><span>$mailer</span> = <span>new</span> Mailer(<span>$email_from</span>, <span>$email_addr</span>, <span>$email_type</span>, <span>$email_host</span>, <span>$email_port</span>, <span>$email_id</span>, <span>$email_pass</span>, <span>$email_ssl</span><span>);<span>//增加 </span></span><span>$mail_result</span> = <span>$mailer</span>->send(<span>$email_test</span>, <span>$email_subject</span>, <span>$email_content</span>, CHARSET, 1<span>); </span><span>if</span> (<span>$mail_result</span><span>) { </span><span>$this</span>->json_result('', 'mail_send_succeed'<span>); } </span><span>else</span><span> { </span><span>$this</span>->json_error('mail_send_failure', <span>implode</span>("\n", <span>$mailer</span>-><span>errors)); } } </span><span>else</span><span> { </span><span>$this</span>->show_warning('Hacking Attempt'<span>); } }</span>
tls方式没有测试过。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

In VS Code, you can run the program in the terminal through the following steps: Prepare the code and open the integrated terminal to ensure that the code directory is consistent with the terminal working directory. Select the run command according to the programming language (such as Python's python your_file_name.py) to check whether it runs successfully and resolve errors. Use the debugger to improve debugging efficiency.

Python excels in automation, scripting, and task management. 1) Automation: File backup is realized through standard libraries such as os and shutil. 2) Script writing: Use the psutil library to monitor system resources. 3) Task management: Use the schedule library to schedule tasks. Python's ease of use and rich library support makes it the preferred tool in these areas.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

VS Code can be used to write Python and provides many features that make it an ideal tool for developing Python applications. It allows users to: install Python extensions to get functions such as code completion, syntax highlighting, and debugging. Use the debugger to track code step by step, find and fix errors. Integrate Git for version control. Use code formatting tools to maintain code consistency. Use the Linting tool to spot potential problems ahead of time.
