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