Reputation: 1645
I'm trying to send custom mail to users, in a module I create these two methods :
/**
* Implements hook_theme().
*/
function ga_planning_theme() {
return array(
'ga_planning_mail_status_change' => array(
'template' => 'templates/ga_planning_mail_status_change',
'variables' => array(),
)
);
}
/**
* Implements hook_mail().
*/
function ga_planning_mail($key, &$message, $params) {
switch ($key) {
case 'status_change_mail':
$message['subject'] = t('Changement de statut');
$message['body'][] = theme('ga_planning_theme', $params);
break;
}
}
And I try to send the mail with drupal_mail :
drupal_mail('ga_planning', 'ga_planning_mail_status_change', "[email protected]", NULL, $params, variable_get('site_mail'), TRUE);
But the mail is not sending, it send a mail to the webmaster mail with the default template and with this subject :
DEBUG - FROM MyWebsite.com
What I am doing wrong ?
Upvotes: 0
Views: 70
Reputation: 454
First,please make sure you can send emails and second: You need to define your $params array. For example:
$params['test'] = 'ok';
And also, try to declare the headers:
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['subject'] = t('Changement de statut');
$message['body'][] = theme('ga_planning_theme', $params);
Upvotes: 1