php - 向检查过 'yes' - php 和 modx 的用户发送电子邮件

标签 php mysql email modx

我有一个“用户评论”数据库,其中包含评论、用户 ID、true/false(如果他们想要通过电子邮件发送)。

我的问题是,如果用户对某个帖子评论 5 次,他们就会在该数据库中出现 5 次,因此他们会收到 5 封相同的电子邮件。这是我的设置:

在数据库中查找想要通过电子邮件发送有关此评论的用户

$ab = $modx->newQuery('Comments');
$ab->leftJoin('modUserProfile','Profile',array('Profile.internalKey = Comments.author'));
$ab->leftJoin('Bulletin','Bulletin',array('Bulletin.id = Comments.bulletin_id'));
$ab->where(array('Comments.bulletin_id' => $bullId));
$ab->where(array('Comments.email' => 1));
$ab->select(array('Comments.*','Profile.fullname as fullname' , 'Profile.email as email' , 'Bulletin.title as title'));
$emailList = $modx->getCollection('Comments',$ab);

现在,给他们发电子邮件

foreach ($emailList as $e){
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->address('to',$e->email);
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_SUBJECT,'A new comment has been posted!');}

我应该使用什么来向用户发送电子邮件,以便无论他们发表的评论有多少,他们都只会收到 1 封电子邮件?如果以上内容还不够清楚,请告诉我。谢谢!!

最佳答案

我认为你可以添加一个groupby...

$ab->groupby('email'); 

选择后

关于php - 向检查过 'yes' - php 和 modx 的用户发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19034486/

相关文章:

php - &lt;!--[if lte IE8]>< ![endif]--> 出现在网站和下拉问题上

mysql - 级联删除触发调用

email - 为什么 CR 和 LF 在电子邮件中一起出现如此重要?

php imap 检查邮件是否有附件

php - 将 worldpay 示例拼接在一起

PHPMAKER,如何创建 View mysql

php - 在 GAE 上用 PHP 解析远程 csv 文件

php - 只有使用用户 ID 1 登录才能看到好友列表

mysql - phpmyadmin 接受查询而 php 带来错误 UNION 和 LIMIT

html - Outlook 2007/2010/2013 邮件显示问题