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

joomla2.5 对一个组群发邮件

WBOY
WBOYOriginal
2016-06-06 19:32:031292browse

无详细内容 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'));
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn