Prestashop - 如何在客户订阅缺货产品时发送电子邮件通知?

问题描述:

我已经使用Mail::Send()函数发送邮件,但它不起作用,为什么?Prestashop - 如何在客户订阅缺货产品时发送电子邮件通知?

文件/mailalerts/controllers/front/actions.php: https://github.com/PrestaShop/mailalerts/blob/master/controllers/front/actions.php

processAdd()功能,if ($mail_alert->add() !== false)之前我已经加入这个:

if ($mail_alert->add() !== false) { 
     die('1'); 

      $product_name = Product::getProductName($id_customer); 
      $shop_email = '[email protected]'; 
      $shop_name = Configuration::get('PS_SHOP_NAME'); 
      $dir_mail = dirname(__FILE__).'/../../mails/'; 
      $template_vars = array(
       '{customer_email}' => $customer_email, 
       '{product_name}' => $product_name 
      ); 

      Mail::Send(
       $id_lang, 
       'new_oos', 
       Mail::l('New request of product', $id_lang), 
       $template_vars, 
       (string)$shop_email, 
       null, 
       (string)$shop_email, 
       (string)Configuration::get('PS_SHOP_NAME', null, null, $id_shop), 
       null, 
       null, 
       $dir_mail, 
       false, 
       $id_shop 
      ); 

    } else { 
     die('0'); 
    } 
} 

如何发送电子邮件给我?

我想你还没有在你的prestashop中配置邮件设置。 要从Prestashop发送电子邮件,您必须通过单击高级首选项 - >电子邮件来配置SMTP。

的表格将是开放的,你必须输入:

Server: smtp.gmail.com (if you uses gmail) 

Username: your gmail id 

Password: your gmail password 

Encryption: SSL 

Port: 465 
+0

邮件设置配置。这不是问题。 P.S:将电子邮件模板(new_oos.html和new_oos.txt)添加到mailalerts/mails/en /文件夹中。 – tRACE

+0

然后,你可以在ActionProductUpdate钩子函数中定义你的代码。 – MAC

+0

我不明白。为了什么?以及如何做到这一点? – tRACE