TShopping

標題: opencart 如何引入mail function 發信 [打印本頁]

作者: woff    時間: 2015-8-1 00:21
標題: opencart 如何引入mail function 發信
小弟最近在改模組
有需要使用到OPENCART的MAIL發信
於是研究了一下
要讓廠商上架商品後發信給管理員
那我們看看怎麼做
後台找到 admin\model\catalog\product.php

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

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

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

  6.                 $mail = new Mail();
  7.                 $mail->protocol = $this->config->get('config_mail_protocol');
  8.                 $mail->parameter = $this->config->get('config_mail_parameter');
  9.                 $mail->hostname = $this->config->get('config_smtp_host');
  10.                 $mail->username = $this->config->get('config_smtp_username');
  11.                 $mail->password = $this->config->get('config_smtp_password');
  12.                 $mail->port = $this->config->get('config_smtp_port');
  13.                 $mail->timeout = $this->config->get('config_smtp_timeout');                               
  14.                 $mail->setTo($this->config->get('config_email'));
  15.                 $mail->setFrom($this->config->get('config_email'));
  16.                 $mail->setSender($this->config->get('config_name'));
  17.                 $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
  18.                 $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
  19.                 $mail->send();
  20.                 //add by woff
複製代碼
這樣就可以了
完程如下圖



作者: 蓦然回首    時間: 2016-3-13 13:25
行,有意义,我顶 谢谢您了




歡迎光臨 TShopping (http://www.tshopping.com.tw/) Powered by Discuz! X3.2