I am developing a module for PrestaShop 1.5.
I am sending email like this(the documentation is really missing, i studied other default components and this is what i got so far)
Mail::Send(
$this->context->language->id, //int $id_lang
'template_name',//string $template
//Mail::l('Hello', $this->context->language->id),//string $subject
$this->l('Email subject'),//string $subject
array('{discount}' => $code,
'{firstname}' => $customer['firstname'],
'{lastname}' => $customer['lastname'],
'{img_url}' => $img_url,
'{valid_days}' => $form['days_valid']
),//string $template_vars
$customer['email'],//string $to
implode(' ', array_filter( array( $customer['firstname'], $customer['lastname']) )),
strval( Configuration::get('PS_SHOP_EMAIL') ),//string $from
strval( Configuration::get('PS_SHOP_NAME') ),//string $from_name
/* null,//string $from
null//string $from_name */
null,//array $file_attachment
null,//$mode_smtp
$template_path//string $template_path /*__PS_BASE_URI__.'modules/'.$this->name.'/mails/' */
);
Note i tried using
Mail::l('Hello', $this->context->language->id),//string $subject
and
$this->l('Email subject'),//string $subject
as the email's subject.
And i keep getting "No Subject was found for …". What the customer receive is the hardcoded string i put in the source code.
So how to get rid of this error:
Plus the emails are sent in apparently random language(sometimes english, sometimes italian).
Best Answer
In your module, you must use Mail::l() in the subject parameter. Here's an example of Mail::Send() for a module :
Here how email translations is working :
AdminTranslationsController will check in "/modules/[module folder]/mails/" for the templates and in "/mails/[lang]/lang.php" for subjects. Subjects will be created when submitting translations.
If that doesn'work, maybe it's a problem with folder's rights. Open this file :
And check if there's a line like this one :
If not, check web server rights on this file and parent folders.