Prestashop:从 BackOffice 激活帐户后无法向用户发送电子邮件
Posted
技术标签:
【中文标题】Prestashop:从 BackOffice 激活帐户后无法向用户发送电子邮件【英文标题】:Prestashop: cannot send email to user after account activation from BackOffice 【发布时间】:2012-05-10 05:29:25 【问题描述】:我到处找,找不到问题的答案。我想在注册时取消激活用户帐户,然后在 BackOffice 中激活它。我设法做到了这一点,但我想在他的帐户被激活时向用户发送一封电子邮件,所以我在激活/取消激活单选按钮旁边添加了一个按钮,我在 AdminCustomers.php 中添加了以下内容
<input type="submit" value="'.$this->l(' Send Email to inform user ').'"/>
但我不知道如何发送电子邮件。我的问题对你来说似乎很简单,但我是 php/html 的新手,所以对我来说有点难。我搜索并找到了许多发送电子邮件的示例,但似乎没有一个有效。
编辑: 我这样做的原因是我们有两种类型的客户:个人和公司。对于公司,我们需要验证提供的信息(例如:增值税号)。然后激活帐户,因为它可以让他们获得特价。
【问题讨论】:
【参考方案1】:您在哪里激活帐户?您应该在帐户激活后添加代码以发送电子邮件 - 添加额外步骤(管理员可能忘记执行)似乎没有意义。
在一个模块中,我会使用如下内容:
private function _emailNewAccount($customer, $address, $messages)
$configuration = Configuration::getMultiple(array('PS_LANG_DEFAULT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'));
$id_lang = (int)$configuration['PS_LANG_DEFAULT'];
$template = 'new_account';
$subject = $this->l('New Account', $id_lang);
$templateVars = array(
'firstname' => $customer->firstname,
'lastname' => $customer->lastname,
'address1' => $address->address1,
'address2' => !empty($address->address2) ? $address->address2 : $this->l('--', $id_lang),
'city' => $address->city,
'postcode' => $address->postcode,
'email' => $customer->email,
'messages' => is_array($messages) ? implode("\n", $messages) : (isset($messages) ? $messages : ''),
'phone' => !empty($address->phone) ? $address->phone : $this->l('n/a', $id_lang),
'mobile' => !empty($address->phone_mobile) ? $address->phone_mobile : $this->l('n/a', $id_lang),
'customer_id' => (int)$customer->id
);
$iso = Language::getIsoById((int)($id_lang));
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') AND file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
Mail::Send($id_lang, $template, $subject, $templateVars, $customer->email,$customer->firstname.' '.$customer->lastname, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], NULL, NULL, dirname(__FILE__).'/mails/');
显然您还需要创建相应的文本和 html 电子邮件模板。在这种情况下,这些将在我的模块目录中: /modules/mymodulename/mails/en/new_account.html /modules/mymodulename/mails/en/new_account.txt
您在模板中使用上面定义的字段,因此对于您可能在new_account.txt
中拥有的纯文本模板:
Hi firstname lastname,
You have just registered on shop_name.
Address:
address1
address2
city, postcode
Telephone: phone, Mobile: mobile
messages
如果您在问题中包含您迄今为止尝试过的内容可能会很好......
【讨论】:
感谢您的回答:)。实际上我这样做的原因是我们有两种类型的客户:个人和公司。对于公司,我们需要验证提供的信息(例如:增值税号)。然后激活帐户,因为它可以让他们获得特价。【参考方案2】:我最终为此创建了一个模块。它与 Prestashop 1.5 完美配合。
【讨论】:
以上是关于Prestashop:从 BackOffice 激活帐户后无法向用户发送电子邮件的主要内容,如果未能解决你的问题,请参考以下文章