开源里有的东西,应该尽量复用,Drupal6要写个群发功能比较花时间,这可以使用action_email_role这个module。它本来是个action,需要trigger来激活。但它里面就有现成的群发功能,只要激活了它,功能就可以用代码调用。
以下是群发例子:
<?php
$context = array(
'subject' => 'Test - send mail to administrator',
'message' => 'The content.',
'recipient' => array(
3 => 'administrator',
5 => 'super administrator'
)
);
$object = new stdClass;
action_email_role_send_email_to_roles($object, $context);