Exemplo n.º 1
0
 /**
  *
  * Send mails to a group of people and check the max number of emailed people limit.
  *
  * @param Project $project Project of the receivers
  * @param PFO_User $user Sender
  * @param string $subject
  * @param string $html_body
  * @param PFUser[] $receivers
  */
 public function sendMassmail(Project $project, PFUser $user, $subject, $html_body, array $receivers)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $project_name = $project->getPublicName();
     $sys_max_number_of_emailed_people = ForgeConfig::get('sys_max_number_of_emailed_people');
     if (count($receivers) > $sys_max_number_of_emailed_people && !$user->isSuperUser()) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('my_index', 'massmail_not_sent_max_users', $sys_max_number_of_emailed_people));
         return;
     }
     $mail = new Codendi_Mail();
     $mail->setFrom($user->getEmail());
     $mail->setTo($user->getEmail());
     $mail->setBccUser($receivers);
     $mail->setSubject("[" . $GLOBALS['sys_name'] . "] [" . $project_name . "] " . $subject);
     $mail->setBodyText($hp->purify($html_body, CODENDI_PURIFIER_STRIP_HTML));
     $mail->setBodyHtml($html_body);
     $is_sent = $mail->send();
     return $is_sent;
 }