Php 覆盖prestashop 1.6中的邮件目录
我正在编写新模块,我想在创建员工帐户后自动向其发送邮件。我重写了AdminEmployeesController控制器,但当我调用Mail::Send()时,最后一个use mails目录位于prestashop项目的根目录中,而不是我在模块根目录中创建的目录Php 覆盖prestashop 1.6中的邮件目录,php,email,module,prestashop,prestashop-1.6,Php,Email,Module,Prestashop,Prestashop 1.6,我正在编写新模块,我想在创建员工帐户后自动向其发送邮件。我重写了AdminEmployeesController控制器,但当我调用Mail::Send()时,最后一个use mails目录位于prestashop项目的根目录中,而不是我在模块根目录中创建的目录 class AdminEmployeesController extends AdminEmployeesControllerCore { /** * Object creation */ public
class AdminEmployeesController extends AdminEmployeesControllerCore
{
/**
* Object creation
*/
public function processAdd()
{
if(parent::processAdd()){
$this->sendMail();
}
}
/*
* Send email to the new employer
* */
public function sendMail()
{
Mail::Send(
$this->context->language->id,
'selcreate_account',
Mail::l('Creation de compte'),
array(
'{firstname}' =>Psql(Tools::getValue('firstname')),
'{lastname}' =>Psql(Tools::getValue('lastname')),
'{passwd}' => Psql(Tools::getValue('passwd')),
'{email}' => Psql(Tools::getValue('email')),
'{shopname}' => 'shop 1',),
Psql(Tools::getValue('email')),
Psql(Tools::getValue('firstname')).' '.Psql(Tools::getValue('lastname')),
$this->context->shop->name
);
}
}
您需要提供模板路径 以下是邮件功能参数:
/**
* Send Email
*
* @param int $id_lang Language of the email (to translate the template)
* @param string $template Template: the name of template not be a var but a string !
* @param string $subject
* @param string $template_vars
* @param string $to
* @param string $to_name
* @param string $from
* @param string $from_name
* @param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files
* @param bool $modeSMTP
* @param string $template_path
* @param bool $die
* @param string $bcc Bcc recipient
*/
public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
$template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
{
这是您的函数(假设您的模板位于模块的邮件目录中):
您应该在send()
中定义目录路径$template\u path
如果您正在创建模块,那么您的路径应该是
_PS_MODULE_DIR_.'yourmodulename/mails/'
希望对您有所帮助。使用此功能,我发现了以下问题:错误-以下模板电子邮件不存在:C:\xampp\htdocs\prestashop\override\controllers\admin/mails/fr/selcreate\u account.txt您需要提供模块的正确路径,以代替目录名(\uu文件)。“/mails/”
我将更新我的答案
_PS_MODULE_DIR_.'yourmodulename/mails/'