$thisHour = date("H"); $result_scheduledEmails = mysql_query("select * from " . $thisdb . ".scheduledmails where email_sent='N' and DAYOFMONTH(email_scheduledon)='{$thisDay}' and MONTH(email_scheduledon)='{$thisMonth}' and YEAR(email_scheduledon)='{$thisYear}' and HOUR(email_scheduledon)='{$thisHour}' "); while ($row = @mysql_fetch_array($result_scheduledEmails)) { extract($row); // sch_emailid, emailby_user, emailby_from, email_to, email_content, email_subject, email_scheduledon, email_sent // send this email from this user to the destination, send a copy to the user $email = new sendaMail(); $containsAt = strpos($emailby_from, '@'); if ($containsAt) { $email->asFrom($emailby_from); } $email->messageTo($email_to); $email->subject($email_subject); $email->body($email_content); if ($email_to != $emailby_from) { $email->AddBCC($emailby_from); } $email->send(); //echo "sending email to ".$email_to ; // mark this email as sent $updated = mysql_query("update " . $thisdb . ".scheduledmails set email_sent='Y' where sch_emailid='{$sch_emailid}' "); } // End of "Scheduled Emails" } // email daily schedule report to serveradmin if (count($ST_emailText)) { $email = new sendaMail(); $email->messageTo(SUPERADMIN_EMAIL); $email->subject('Daily cron - scheduled tasks for ' . date("d-m-Y")); $email->body(implode("<BR>", $ST_emailText)); $email->send();