/**
* Send a Notification mail after CRON RAN
* to the admin user.
*/
function sendCRonNotificationMailtoAdmin($key) {
// set up the to and from
//this has to be from your server, or you could get blocked by spam blocker
$email_from = "from@gmail.com";
// Recipient mail ID in the $to variable.
$to = 'to@gmail.com';
//pass mail subject through this variable.
$subject = "Mail Subject Text";
//pass mail body content through this variable.
$mail_body = "Mail Body Text";
//build an array called $params to pass whatever you want to the email
$params['subject'] = $subject ;
$params['body'] = $mail_body;
$sent = drupal_mail('Module-Name', 'Module-Name_mail', $to, language_default(), $params, $email_from, TRUE);
}
// Responsible to build the mail function
// based on the module
function Module-Name_mail($key, &$message, $params) {
$language = $message['language'];
switch($key) {
//switching on $key lets you create variations of the email based on the $key parameter
case 'Module-Name_mail': // $key should be 'VECO' in the mail function
$message['subject'] = $params['subject'];
$message['body'][] = $params['body'];
// Cc to the multiple recipient.
$message['headers']['Cc'] = 'cc@gmail.com';
// Bcc to the multiple recipient.
$message['headers']['Bcc'] = 'bcc@gmail.com';
break;
}
}
// once this been done
//then you call the below function
// where exactly this needs to execute
sendCRonNotificationMailtoAdmin($key);
| Comment | File | Size | Author |
|---|---|---|---|
| drupal-mail-function.txt | 1.54 KB | shankar javali |
Comments
Comment #2
cilefen commentedThis issue seems to have no purpose. But, at least it is fixed!
Seriously, what is going on here?
Comment #3
shankar javali commentedThis is not an issue this is the document which i experienced to solve the mail issues in my custom module.
The way how i achieved through send a mail after the cron job.
Comment #4
shankar javali commentedComment #5
cilefen commented@shankar javali
For your future reference, the core issue queue is not the place for hints and tips. A better place could be the snippets.