Opencart: modifying email layouts

前端 未结 1 1941
礼貌的吻别
礼貌的吻别 2021-01-25 14:01

I\'m running Opencart Version 2.0.1.1. I need a way of editing the layout of the registration and order update email.

By this, I mean control the full

1条回答
  •  走了就别回头了
    2021-01-25 14:05

    i had same problem but i used mailgun lib to send my mails and i can use html/css templates :)

    if you like follow this steps: 1-download mailgun lib https://github.com/mailgun/mailgun-php

    2- you have to edit system mail system or add your function to opencart system : (i change mail function opencart totaly) i add this codes to /system/library/mail.php rename send() to oldsend() or whatever you want

        //extracted mailgun lib address
        require 'mailgun/autoload.php';
        use Mailgun\Mailgun;
    
            public function send(){
            $mg = new Mailgun("mailgunkey goeshere");
            $domain = "your domain code";
    
            $mg->sendMessage($domain, array(
                'from'    => $this->from , 
                'to'      => $this->to , 
                'subject' => $this->subject , 
                'text'    => $this->text , 
                'html'    => $this->html
                ));
        }
    

    as a example for sending mail:

         $data['text_discount'] = 'text';
    
            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/welcome.tpl')) {
                $html = $this->load->view($this->config->get('config_template') . '/template/mail/welcome.tpl', $data);
            } else {
                $html = $this->load->view('default/template/mail/welcome.tpl', $data);
            }
    $mail->setTo($data['email']);
            $mail->setFrom($this->config->get('config_email'));
            $mail->setSender(html_entity_decode($this->config->get('config_name'),ENT_QUOTES, 'UTF-8'));
            $mail->setSubject($subject);
            $mail->setHtml($html);
            $mail->send();
    

    this is just basic example :)

    0 讨论(0)
提交回复
热议问题