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

joomla2.5 对一个组群发邮件

WBOY
發布: 2016-06-06 19:32:03
原創
1295 人瀏覽過

无详细内容 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'));
}
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板