woff 發表於 2015-8-1 00:21:15

opencart 如何引入mail function 發信

小弟最近在改模組
有需要使用到OPENCART的MAIL發信
於是研究了一下
要讓廠商上架商品後發信給管理員
那我們看看怎麼做
後台找到 admin\model\catalog\product.php

在function addProduct最後
大括弧上 "}"
加入
//add by woff
                $this->language->load('mail/customer');

                $subject =$this->config->get('config_name')." 有廠商商品上架嚕";

                $message = $this->config->get('config_name')." 親愛的管理員你好\n\n";
                $message .= "有廠商商品上架嚕 \n\n";

                $mail = new Mail();
                $mail->protocol = $this->config->get('config_mail_protocol');
                $mail->parameter = $this->config->get('config_mail_parameter');
                $mail->hostname = $this->config->get('config_smtp_host');
                $mail->username = $this->config->get('config_smtp_username');
                $mail->password = $this->config->get('config_smtp_password');
                $mail->port = $this->config->get('config_smtp_port');
                $mail->timeout = $this->config->get('config_smtp_timeout');                               
                $mail->setTo($this->config->get('config_email'));
                $mail->setFrom($this->config->get('config_email'));
                $mail->setSender($this->config->get('config_name'));
                $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
                $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
                $mail->send();
                //add by woff這樣就可以了
完程如下圖


蓦然回首 發表於 2016-3-13 13:25:36

行,有意义,我顶 谢谢您了
頁: [1]
查看完整版本: opencart 如何引入mail function 發信