Opencart: modifying email layouts

让人想犯罪 __ 提交于 2019-12-02 07:05:51

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 :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!