public static function sendMail($dbh, $cron, $file, $subject = "[CRON MANAGER] Task Completed") { require_once (GenConfig::LOCATION == 2 ? System::L_SYSTEM_PATH : System::D_SYSTEM_PATH) . "includes/emailSpool/class.emailSpool.php"; $email = new EmailSpool(); $email->fromName = "TrafficSynergy CRON Manager"; $email->fromAdd = "*****@*****.**"; $email->toAddress = $cron["email_address"]; # self::getToAddress($id, $dbh); # can be , seperated ; seperated or array $cc = self::getCCAddresses($cron["cron_id"], $dbh); $bcc = self::getBCCAddresses($cron["cron_id"], $dbh); if (!empty($cc)) { $email->ccAddress = $cc; # can be , seperated ; seperated or array } if (!empty($bcc)) { $email->bccAddress = $bcc; # can be , seperated ; seperated or array } $email->fileAttach = array($file); # array of filenames # $email->htmlBody = file_get_contents($file); #html body - if you want to send an text email set only the textBody $email->textBody = file_get_contents($file); #this can be the alt Body or text only body $email->priority = 4; #1 is low 5 is high default 3 $email->subject = $subject; $email->program = "CronManager"; $email->key = $cron["cron_id"]; # $id; # (Optional) A key to identify this email in the context of the program [idnumber/transactionID] $email->ref = ""; # (Optional) Ref to who send the email. Blank for auto email if ($_id = $email->submitEmail()) { # returns an unique id that is a reference to the inserted email SR_Agent::Log(GenConfig::API, SystemReporter::MSG_MESSAGE, "Mail message sent, id #" . $_id); return "Message was sent successfully with ID : %lightblue%{$_id}%white% \n"; } else { SR_Agent::Log(GenConfig::API, SystemReporter::MSG_ERROR, "There was an error sending the message :" . $email->error . "\n"); return "There was an error sending the message : %red%" . $email->error . "%white%\n"; } }