2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2008-02-25 03:10:37 +01:00
|
|
|
/**
|
|
|
|
* Daily task to send queued email.
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage email
|
|
|
|
*/
|
2007-07-19 12:40:28 +02:00
|
|
|
class QueuedEmailDispatchTask extends DailyTask {
|
|
|
|
|
|
|
|
public function process() {
|
2007-08-21 01:01:17 +02:00
|
|
|
if(ini_get("safe_mode") != "1") {
|
|
|
|
set_time_limit(0);
|
|
|
|
}
|
2007-07-19 12:40:28 +02:00
|
|
|
|
|
|
|
echo "SENDING QUEUED EMAILS\n";
|
|
|
|
|
2009-03-11 22:50:03 +01:00
|
|
|
$queued = DataObject::get('QueuedEmail', "\"Send\" < " . DB::getConn()->now());
|
2007-07-19 12:40:28 +02:00
|
|
|
|
|
|
|
if( !$queued )
|
|
|
|
return;
|
|
|
|
|
|
|
|
foreach( $queued as $data ) {
|
|
|
|
|
|
|
|
if( !$data->canSendEmail() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$data->send();
|
|
|
|
echo 'Sent to: ' . $data->To()->Email . "\n";
|
|
|
|
|
|
|
|
$data->delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|