你在哪里激活帐户?您应该只添加代码以在激活帐户后发送电子邮件 - 添加额外步骤(管理员可能忘记执行)似乎没有意义。
在一个模块中,我将使用如下内容:
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}
如果您在问题中包含您迄今为止尝试过的内容可能会很好......