服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > php教程 >

opencart安装和使用PHPMailer(2)

时间:2015-11-16 11:45来源:未知 作者:最模板 点击:
修复后的xml: modification idPHPMailer/id version2.0/version vqmver1.0.4/vqmver authorSpotOnSolutions.net/author file name=system/library/mail.php operation search position=before![CDATA[ class M

修复后的xml:

<modification>
 
    <id>PHPMailer</id>
    <version>2.0</version>
    <vqmver>1.0.4</vqmver>
    <author>SpotOnSolutions.net</author>
    
    <file name="system/library/mail.php">
        <operation>
            <search position="before"><![CDATA[
            class Mail
            ]]></search>
            <add><![CDATA[include_once(DIR_SYSTEM . 'library/phpmailer/class.phpmailer.php');]]></add>
        </operation>
 
        <operation>
            <search position="before"><![CDATA[
                protected $subject;
            ]]></search>
            <add><![CDATA[    protected $readreceipt;]]></add>
        </operation>
 
        <operation>
            <search position="before"><![CDATA[
                public function setSubject
            ]]></search>
            <add><![CDATA[    public function setReadReceipt($readreceipt) {
        $this->readreceipt = $readreceipt;
    }
            ]]></add>
        </operation>
 
        <operation>
            <search position="before"><![CDATA[public function send() {]]></search>
            <add><![CDATA[/*]]></add>
        </operation>
        
        <operation>
            <search position="bottom" offset="2"><![CDATA[
            public function send() {
            ]]></search>
            <add><![CDATA[*/
    public function send() {
        if (!$this->to) {
            trigger_error('Error: E-Mail to required!');
            exit();            
        }
 
        if (!$this->from) {
            trigger_error('Error: E-Mail from required!');
            exit();                    
        }
 
        if (!$this->sender) {
            trigger_error('Error: E-Mail sender required!');
            exit();                    
        }
 
        if (!$this->subject) {
            trigger_error('Error: E-Mail subject required!');
            exit();                    
        }
 
        if ((!$this->text) && (!$this->html)) {
            trigger_error('Error: E-Mail message required!');
            exit();                    
        }
        
        $mail  = new PHPMailer();
        $mail->CharSet = "UTF-8";
        
        if (is_array($this->to)) {
            foreach ($this->to as $toTmp){
                $mail->AddAddress($toTmp);
            }
        } else {
            $mail->AddAddress($this->to);
        }
 
        if(!empty($this->readreceipt)) {
            $mail->ConfirmReadingTo = $this->readreceipt;
        }
 
        $mail->Subject = $this->subject;
        
        $mail->AddReplyTo($this->from, $this->sender);
        $mail->SetFrom($this->from, $this->sender);
        $mail->AddReplyTo($this->from, $this->sender);
        
        if (!$this->html) {
            $mail->Body = $this->text;
        } else {
            $mail->MsgHTML($this->html);
            if ($this->text) {
                $mail->AltBody = $this->text;
            } else {
                $mail->AltBody = 'This is a HTML email and your email client software does not support HTML email!';
            }
        }
 
        foreach ($this->attachments as $attachment) {
            if (file_exists($attachment['file'])) {
                $mail->AddAttachment($attachment['file']);
            }
        }
 
        if ($this->protocol == 'smtp') {
            $mail->IsSMTP();
            $mail->Host = $this->smtp_hostname;
            $mail->Port = $this->smtp_port;
            if($this->smtp_port == '587'){
                $mail->SMTPAuth = true;
                $mail->SMTPSecure = "tls";
            } elseif ($this->smtp_port == '465') {
                $mail->SMTPAuth = true;
                $mail->SMTPSecure = "ssl";
            }
            if (!empty($this->smtp_username)  && !empty($this->smtp_password)) {
                $mail->SMTPAuth = true;
                $mail->Host = $this->smtp_hostname;
                $mail->Username = $this->smtp_username;
                $mail->Password = $this->smtp_password;
            }
        }
        $mail->Send();
            ]]></add>
        </operation>
 
    </file>
    
</modification>
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容