コード例 #1
0
 public function send_report(IncidentInterface $incident, $body = null, $echo = null, $is_new_incident = FAlSE)
 {
     if (!$echo) {
         if ($incident->getSendReport() || $is_new_incident) {
             $html = $this->getBody($incident);
             $text = strip_tags($this->getBody($incident, 'txt'));
             $message = \Swift_Message::newInstance()->setSubject(sprintf($this->environment . '[CERTunlp] Incidente de tipo "%s" en el host %s [ID:%s]', $incident->getType()->getName(), $incident->getHostAddress(), $incident->getId()))->setFrom($this->cert_email)->setCc($this->cert_email)->setTo($incident->getNetworkAdmin()->getEmail())->setBody($text)->addPart($html, 'text/html');
             if ($incident->getEvidenceFilePath()) {
                 $message->attach(\Swift_Attachment::fromPath($this->upload_directory . $incident->getEvidenceFilePath(true)));
             }
             if ($incident->getReportMessageId()) {
                 $message->setId($incident->getReportMessageId());
             }
             $this->mailer->send($message);
         }
     } else {
         $html = $this->getBody($incident);
         echo $html;
     }
 }