将同一封电子邮件多次发送给同一用户

问题描述 投票:-1回答:1

我想在管理员创建新事件时将电子邮件发布给用户。电子邮件正在触发,但学生多次收到相同的电子邮件。我在代码中使用了每个。任何帮助赞赏。

   $this->properties->id = $DB->insert_record('event', $this->properties);
   $tooo = $DB->get_record('role', array('shortname' => 'student'));
   $too =  $DB->get_records('role_assignments', array('roleid' => $tooo->id));
   $pageNos = array();
   foreach($too as $new)
   {
      $t = $DB->get_record('user', array('id' => $new->userid));
       // if(!in_array($t,$pageNos)){
      $body = "event has been posted by {$USER->username} : {$content} on student assignment "; 
      email_to_user($t,$USER,'event Notification ','The text of the message',$body);
   }
php
1个回答
-1
投票

你可以这样试试

$this->properties->id = $DB->insert_record('event', $this->properties);
$tooo = $DB->get_record('role', array('shortname' => 'student'));
$too =  $DB->get_records('role_assignments', array('roleid' => $tooo->id));
$pageNos = array();
foreach($too as $new)
{
   if(!in_array($new->userid,$pageNos))
   {
     $t = $DB->get_record('user', array('id' => $new->userid));
     $body = "event has been posted by {$USER->username} : {$content} on student assignment "; 
     email_to_user($t,$USER,'event Notification ','The text of the message',$body);
     $pageNos[] = $new->userid;
   }
}
© www.soinside.com 2019 - 2024. All rights reserved.