首页 >php教程 >php手册 >joomla2.5 对一个组群发邮件

joomla2.5 对一个组群发邮件

WBOY
WBOY原创
2016-06-06 19:32:031292浏览

无详细内容 Joomla $app = JFactory::getApplication();$acl = JFactory::getACL();$db = JFactory::getDbo();$groupId = 10;$uIds = $acl-getUsersByGroup($groupId, false);$query = $db-getQuery(true);$query-select('email');$query-from('#__users');$q

Joomla
$app    = JFactory::getApplication();
$acl    = JFactory::getACL();
$db     = JFactory::getDbo();

$groupId = 10;

$uIds = $acl->getUsersByGroup($groupId, false);
$query = $db->getQuery(true);
$query->select('email');
$query->from('#__users');
$query->where('id IN (' . implode(',', $uIds) . ')');
$query->where("block = 0 AND sendEmail = 1");
$db->setQuery($query);
$rows = $db->loadColumn();

$mailer = JFactory::getMailer();
$mailer->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
$mailer->setSubject($subject);
$mailer->setBody($body);
$mailer->IsHTML(true);
$mailer->addRecipient($rows);
if (!$mailer->Send()) {
  JError::raiseWarning(500, JText::_('ERROR_SENDING_EMAIL'));
}
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn