You made a PHP script associated to a Drupal module and you want to be alerted of custom special events or big fails
In your module file, just implement the hook_mail() like this :
1 |
function <modulename>_mail($key, &$message, $params) {} |
Now you can send what you want from your script
1 2 3 4 5 6 7 8 9 10 11 |
$body = array(); $body[] = "This is my content:"; $body[] = '<pre>'.print_r($custom_array_to_display,true).'</pre>'; $body[] = $some_value_to_display; $mail_message = drupal_mail($modulename, $key, $to, language_default(), array(),$from,FALSE); // $to can contain multiple values separated with a comma $mail_message['subject'] = 'Here is my subject'; $mail_message['body'] = $body; $mail_system = drupal_mail_system($modulename, $key); $mail_message = $mail_system->format($mail_message); $mail_message['result'] = $mail_system->mail($mail_message); |
By the way, I had so much template problems with this function that I finally used the default PHP mail() function:
1 2 |
$headers = "From:".$from; mail($to,$subject,$message,$headers); |
Recent Comments