来源:http://trac.seagullproject.org/wiki/Modules/EmailQueue

Email Queue模块

概述

这个模块允许选择发送邮件的后台,并且可以控制它们发送的速度。默认包含了DB后台驱动器。

例子

如何添加到队列

  • 安装emailqueue模块
  • 使用SGL_Emailer2::send,在可选的第三个参数指定队列参数,如:
...
// delivery options
$aDeliveryOpts['toEmail']  = 'your data here';
$aDeliveryOpts['toRealName'] = 'your data here';
...
$aDeliveryOpts['fromEmail'] = 'your data here';.
$aDeliveryOpts['fromRealName']  = 'your data here';

// template vars
$aTplOpts['var1'] = 'val1';
$aTplOpts['var2'] = 'val2';
$aTplOpts['var3'] = 'val3';

// obligatory template options
$aTplOpts['moduleName']    = 'mymodule';
$aTplOpts['htmlTemplate']  = 'mytemplate.html';
$aTplOpts['textTemplate'] = 'mytemplate.txt';

// optionally send emails to queue for later sending
$aQueueOpts['sendDelay'] = 'your send delay';.
$aQueueOpts['groupId']  = 'your group';
$aQueueOpts['userId']  = 'your user ID';
$aQueueOpts['batchId']  = 'your batch ID';

$ok = SGL_Emailer2::send($aDeliveryOpts, $aTplOpts, $aQueueOpts);

如何从队列中发送

  • 设置一个cronjob来定期发送,如让它每天发送
php www/index.php --moduleName=emailqueue --managerName=emailqueue --action=process --deliveryDate=2008-04-08
php www/index.php --moduleName=emailqueue --managerName=emailqueue --action=process --deliveryDate=all
php www/index.php --moduleName=emailqueue --managerName=emailqueue --action=flush

上面的所有命令具有一样的效果。要获取所有的参数选项,执行下列命令:

php www/index.php --moduleName=emailqueue --managerName=emailqueue
 
modules/emailqueue.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2