Ecmall How to support the configuration of SSL-connected mail servers _php Tutorial

Source: Internet
Author: User
First, the Phpmailer version used primarily by Ecmall is too low and does not support encrypted connections.

Then, you have to make some adjustments to the corresponding code.

1. Cover Phpmailer

Please download from the attachment:

Http://files.cnblogs.com/x3d/ecmall_phpmailer_lib.zip

2. Transform Lib

Involving two lib:mail.lib.php, mail_quequ.lib.php

In the constructors for these two classes, add a parameter pass. such as Mailer

function __construct ($from$email$protocol$host$port$ User$pass$SMTPSecurefalse)//Add $SMTPSecure    {         $this->mailer ($from$email$protocol$host$port  $user$pass$SMTPSecure);    }     function Mailer ($from$email$protocol$host$port$user $pass $SMTPSecure false )....

MailQueue in the same vein.

3. Encapsulating the Calling function

global.lib.php approx. 300 lines

Add a line to function &get_mailer ():

$secure   = Conf::get (' Email_ssl ');//Add this        line $mailerNew Mailer ($sender$from $protocol $host $port $username $password $secure); /pass parameters at the same time

4. Adjust the background email settings interface, add the relevant settings

Background Template: setting.email_setting.html Add a configuration item

< TR >                <  class= "paddingT15">                     Mail Server encryption method:
  
    th  >                <class= "paddingT15 wordSpacing5"  >                    {html_radios name= "Email_ssl" options= $email _ssl checked= $setting. Email_ssl}                     <  class= "Field_notice"> 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 support for this module 
   
     label>                
    
      td>             
     
       tr>    

Also, modify the parameter passing of the message test

<Scripttype= "Text/javascript">$(function(){    $('#send_test_email'). Click (send_test_email);});functionSend_test_email () {varEmail_type= $('input[name= "Email_type"]:checked'). Val (); varEmail_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> 
 

Then you need to modify the setting.app.php

/** * EMAIL settings * * @author hyber * @return void*/    functionemail_setting () {$model _setting= &af (' Settings '); $setting=$model _setting->getall ();//Loading 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( 0 = lang::get (' no '), 1 = ' SSL ', 2 = ' 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 ']; //Increase $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 message methods.

functionSend_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 ']; //Increase $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 '); /*using the Mailer class*/Import (' Mailer.lib '); $mailer=NewMailer ($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.

http://www.bkjia.com/PHPjc/771648.html www.bkjia.com true http://www.bkjia.com/PHPjc/771648.html techarticle First, the Phpmailer version used primarily by Ecmall is too low and does not support encrypted connections. Then, you have to make some adjustments to the corresponding code. 1. Overwrite the Phpmailer please download from the attachment: http: ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.