Dante Job Scheduler: Sending Paralell Email with the Crossley Framework

Delaying actions until times of lower traffic and completely offloading jobs to specialized servers are classic ways to scale. Also, the classic way to demonstrate how this works and the benefits is by sending an email. So here is the obligatory email example with the Crossley framework:

$oJob = new X_Scheduler_Job(X_Scheduler_Job::TYPE_PHP);
$oJob->setScript('email_script.php');
$oJob->setVariable('sFrom', 'me@example.com');
$oJob->setVariable('sTo', 'you@example.com');
$oJob->setVariable('sSubject', 'A Test Email');
$oJob->setVariable('sBody', 'This is a test, Yo!');
$oJob->register();

Let me explain what is happening here. We are creating a PHP task by passing the PHP Type constant to the Scheduler Job class. We set the PHP script to ’email_script.php’. The contents of this script could be something as simple as the following:


$sHeaders = 'From: ' . $sFrom . "\r\n" .
'Reply-To: ' . $sFrom . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($sTo, $sSubject , $sBody, $sHeaders);

You notice the php variables used here, one way to set these values is via the setVariable() method of the X_Scheduler_Job object. These are then reset within it’s scope prior to executing the script.

While this functionality is very much at an alpha stage, you can watch Dante and The Crossley Framework develop on Google code or at dante.drydenproject.com.

Advertisements
Dante Job Scheduler: Sending Paralell Email with the Crossley Framework

One thought on “Dante Job Scheduler: Sending Paralell Email with the Crossley Framework

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s