


Detailed explanation of the configuration method of ECMall supporting SSL connection to the mail server_PHP tutorial
First of all, the main reason is that the phpmailer version used by ecmall is too low and does not support encrypted connections.
Then, you have to make certain adjustments to the corresponding code.
1. Cover phpmailer
Please download from the attachment:
http://cywl. jb51.net:81/201405/yuanma/ecmall_phpmailer_lib(jb51.net).zip
2. Modify lib
Involves two libs: mail.lib.php, mail_quequ.lib.php
In the constructors of these two classes, add a parameter to pass. Such as Mailer
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 applies to MailQueue.
3. Encapsulate calling functions
global.lib.php is about 300 lines
Add a line in function &get_mailer():
$secure = Conf::get('email_ssl');//Add this line
$mailer = new Mailer($sender, $from, $protocol, $host, $port, $username, $password, $secure);//Pass parameters at the same time
4. Adjust the background email setting interface and add related setting items
Backend template: setting.email_setting.html Add a configuration item
class="field_notice">This function requires that your php must support the OpenSSL module. If you want to use this function, please contact your space provider to confirm that it supports this module
/**
* EMAIL Settings
*
* @author Hyber
* @return void
*/
function email_setting()
{
$model_setting = &af('settings');
$setting = $model_setting->getAll(); //载入系统设置数据
if (!IS_POST)
{
$this->assign('setting', $setting);
$this->assign('mail_type', array(
MAIL_PROTOCOL_SMTP => Lang::get('smtp'),
MAIL_PROTOCOL_LOCAL => Lang::get('email'),
));
//增加
$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'];//增加
$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');
}
}
以及测试邮件方法。
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'];//增加
$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');
/* 使用mailer类 */
import('mailer.lib');
$mailer = new Mailer($email_from, $email_addr, $email_type, $email_host, $email_port, $email_id, $email_pass, $email_ssl);//增加
$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');
}
}
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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

Alipay PHP...

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
