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";
|
|
|
|
|
|
|
|
$queued = DataObject::get('QueuedEmail', "`Send` < NOW()");
|
|
|
|
|
|
|
|
if( !$queued )
|
|
|
|
return;
|
|
|
|
|
|
|
|
foreach( $queued as $data ) {
|
|
|
|
|
|
|
|
if( !$data->canSendEmail() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$data->send();
|
|
|
|
echo 'Sent to: ' . $data->To()->Email . "\n";
|
|
|
|
|
|
|
|
$data->delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|