/**
* 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);

CommentFileSizeAuthor
drupal-mail-function.txt1.54 KBshankar javali

Comments

shankar javali created an issue. See original summary.

cilefen’s picture

Issue tags: -Drupal mail function, -drupal_mail, -cron_mail, -send mail after cron run

This issue seems to have no purpose. But, at least it is fixed!

Seriously, what is going on here?

shankar javali’s picture

This 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.

shankar javali’s picture

Issue summary: View changes
cilefen’s picture

@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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.