Version: current

     1 <?php
     2 /**
     3  * Daily task to send queued email.
     4  * @package sapphire
     5  * @subpackage email
     6  */
     7 class QueuedEmailDispatchTask extends DailyTask {
     8
     9     public function process() {
    10         increase_time_limit_to();
    11
    12         echo "SENDING QUEUED EMAILS\n";
    13
    14         $queued = DataObject::get('QueuedEmail', "\"Send\" < " . DB::getConn()->now());
    15
    16         if( !$queued )
    17             return;
    18
    19         foreach( $queued as $data ) {
    20
    21             if( !$data->canSendEmail() )
    22                 continue;
    23
    24             $data->send();
    25             echo 'Sent to: ' . $data->To()->Email . "\n";
    26
    27             $data->delete();
    28         }
    29     }
    30
    31 }
    32 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -