#!/usr/bin/php id); define("INTERNAL_USER_USERNAME", $me->username); define("MFBASE_BYPASS_LOGIN", true); /*$dispatch = new MailtemplateDispatch(1); $emails = $dispatch->getRecipients(true); echo "empfänger emails: ".count($emails)."\n"; //$dispatch->sendToRecipients("fronk@fronk.at"); */ foreach(MailtemplateDispatch::search(["send_finish" => null, "send_lock" => null]) as $dispatch) { // check tosend date if(!$dispatch->tosend_date || $dispatch->tosend_date > date('U')) continue; // get notification again from DB in case send_lock was set $dispatch = new MailtemplateDispatch($dispatch->id); if($dispatch->send_lock) continue; // first of all set send lock and start date $mypid = getmypid(); if(!$dispatch->send_start) { $dispatch->send_start = date("U"); } $dispatch->send_lock = ($mypid) ? $mypid : 1; $dispatch->save(); $dispatch->sendToRecipients(); // get Dispatch from DB again and update send lock and finish date $dispatch = new MailtemplateDispatch($dispatch->id); $dispatch->send_finish = date('U'); $dispatch->send_lock = null; $dispatch->save(); }