This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/email_queue/email_queue.inc.php

68 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
2009-08-03 04:10:16 +00:00
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
2009-08-03 04:10:16 +00:00
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
2009-08-03 04:10:16 +00:00
* @subpackage Module:EmailQueue
*/
2009-08-03 04:10:16 +00:00
/**
* The main AgileBill Email Queue Class
*
* @package AgileBill
* @subpackage Module:EmailQueue
*/
class email_queue extends OSB_module {
/**
* Send mails in the queue
*/
public function send($VAR) {
$db = &DB();
$rs = $db->Execute(sqlSelect($db,'email_queue','*',array('status'=>0)));
if ($rs && $rs->RecordCount()) {
require_once(PATH_MODULES.'email_template/email_template.inc.php');
while (! $rs->EOF) {
# Get values
$sql = array();
$sql[1] = $rs->fields['sql1'];
$sql[2] = $rs->fields['sql2'];
$sql[3] = $rs->fields['sql3'];
# Unserialize the SQL data if required.
foreach ($sql as $i)
if (preg_match('/^a:/',$sql[$i]) && is_array($a = unserialize($sql[$a])))
$sql[$i] = $a;
# Send email
$mail = new email_template;
2009-08-03 04:10:16 +00:00
$result = $mail->send($rs->fields['email_template'],$rs->fields['account_id'],$sql[1],$sql[2],$sql[3],false);
# Update to sent status
2009-08-03 04:10:16 +00:00
if ($result)
$db->Execute(sqlUpdate($db,'email_queue',array('status'=>1),array('id'=>$rs->fields['id'])));
$rs->MoveNext();
}
}
}
}
2009-08-03 04:10:16 +00:00
?>