mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Removed unused QueuedEmail and QueuedEmailDispatchTask
This commit is contained in:
parent
b1f27b40ce
commit
59230d8e39
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Stores a queued email to be sent at the given time
|
|
||||||
* @package sapphire
|
|
||||||
* @subpackage email
|
|
||||||
*/
|
|
||||||
class QueuedEmail extends DataObject {
|
|
||||||
|
|
||||||
static $db = array(
|
|
||||||
'Send' => 'SS_Datetime',
|
|
||||||
'Subject' => 'Varchar',
|
|
||||||
'From' => 'Varchar',
|
|
||||||
'Content' => 'Text'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $has_one = array(
|
|
||||||
'To' => 'Member'
|
|
||||||
);
|
|
||||||
|
|
||||||
static $has_many = array();
|
|
||||||
|
|
||||||
static $many_many = array();
|
|
||||||
|
|
||||||
static $defaults = array();
|
|
||||||
|
|
||||||
// overwrite this method to provide a check whether or not to send the email
|
|
||||||
function canSendEmail() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function send() {
|
|
||||||
$email = new Email( $this->From, $this->To()->Email, $this->Subject, $this->Content );
|
|
||||||
$email->send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Daily task to send queued email.
|
|
||||||
* @package sapphire
|
|
||||||
* @subpackage email
|
|
||||||
*/
|
|
||||||
class QueuedEmailDispatchTask extends DailyTask {
|
|
||||||
|
|
||||||
public function process() {
|
|
||||||
increase_time_limit_to();
|
|
||||||
|
|
||||||
echo "SENDING QUEUED EMAILS\n";
|
|
||||||
|
|
||||||
$queued = DataObject::get('QueuedEmail', "\"Send\" < " . DB::getConn()->now());
|
|
||||||
|
|
||||||
if( !$queued )
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach( $queued as $data ) {
|
|
||||||
|
|
||||||
if( !$data->canSendEmail() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$data->send();
|
|
||||||
echo 'Sent to: ' . $data->To()->Email . "\n";
|
|
||||||
|
|
||||||
$data->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
Reference in New Issue
Block a user