add class Westdc\Mail\Queue

This commit is contained in:
Jianxuan Li 2015-01-03 22:29:35 +08:00
parent 414b8f1f73
commit 40b58bda04
2 changed files with 78 additions and 0 deletions

41
Westdc/Mail/Queue.php Normal file
View File

@ -0,0 +1,41 @@
<?php
/**
* Created by PhpStorm.
* User: liujin834
* Date: 15/1/3
* Time: 下午9:57
*/
namespace Westdc\Mail;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Westdc\EventModel\AbstractEventManager;
class Queue extends AbstractEventManager implements ServiceManagerAwareInterface{
protected $serviceManager;
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
$this->init();
return $this;
}
private function init()
{
}
public function add(){
}
public function show(){
}
}

View File

@ -24,6 +24,11 @@ class Sender implements ServiceManagerAwareInterface{
return $this;
}
/**
* 发送即时邮件
* @param $options
* @return bool
*/
public function backend($options)
{
$cmd = "php ".CURRENT_BOOTSTRAP_SCRIPT;
@ -50,4 +55,36 @@ class Sender implements ServiceManagerAwareInterface{
return true;
}
/**
* 将邮件添加到发送列队降低内存和cpu消耗但是用户无法即时收到适用于通知类型的邮件和大批量发送的邮件
* @param $options
* @return bool
*/
public function queue($options)
{
$cmd = "php ".CURRENT_BOOTSTRAP_SCRIPT;
$cmd .= ' mail queue';
$cmd .= ' --email="'.$options['email'].'"';
$cmd .= ' --name="'.$options['name'].'"';
$cmd .= ' --template="'.$options['template'].'"';
if(isset($options['data']))
{
$data = json_encode($options['data']);
$cmd .= ' --data=\''.$data.'\'';
}
$tools = $this->serviceManager->get('Tools');
if($this->debug == 0)
{
$tools->execBackend($cmd);
return true;
}
var_dump($tools->execFront($cmd));
return true;
return true;
}
}