mirror of https://github.com/MISP/MISP
new: [mail] Add reference for event alert emails
parent
17fb5db3cf
commit
56508cce17
|
@ -441,15 +441,25 @@ class SendEmail
|
|||
if ($body instanceof SendEmailTemplate) {
|
||||
$body->set('canEncryptSmime', $canEncryptSmime);
|
||||
$body->set('canEncryptGpg', $canEncryptGpg);
|
||||
$body = $body->render($hideDetails);
|
||||
$bodyContent = $body->render($hideDetails);
|
||||
} else {
|
||||
if ($hideDetails && $bodyWithoutEncryption) {
|
||||
$body = $bodyWithoutEncryption;
|
||||
}
|
||||
$body = new CakeEmailBody($body);
|
||||
$bodyContent = new CakeEmailBody($body);
|
||||
}
|
||||
|
||||
$email = $this->create($user, $subject, $body, [], $replyToUser);
|
||||
$email = $this->create($user, $subject, $bodyContent, [], $replyToUser);
|
||||
|
||||
// Generate `In-Reply-To` and `References` to group emails
|
||||
if ($body instanceof SendEmailTemplate && $body->referenceId()) {
|
||||
$reference = sha1($body->referenceId() . '|' . Configure::read('MISP.uuid'));
|
||||
$reference = "<$reference@{$email->domain()}>";
|
||||
$email->addHeaders([
|
||||
'In-Reply-To' => $reference,
|
||||
'References' => $reference,
|
||||
]);
|
||||
}
|
||||
|
||||
$signed = false;
|
||||
if (Configure::read('GnuPG.sign')) {
|
||||
|
|
|
@ -7,12 +7,29 @@ class SendEmailTemplate
|
|||
/** @var string */
|
||||
private $viewName;
|
||||
|
||||
/** @var string|null */
|
||||
private $referenceId;
|
||||
|
||||
public function __construct($viewName)
|
||||
{
|
||||
$this->viewName = $viewName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This value will be used for grouping emails in mail client.
|
||||
* @param string|null $referenceId
|
||||
* @return string
|
||||
*/
|
||||
public function referenceId($referenceId = null)
|
||||
{
|
||||
if ($referenceId === null) {
|
||||
return $this->referenceId ;
|
||||
}
|
||||
$this->referenceId = $referenceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set template variable.
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
|
@ -29,6 +46,7 @@ class SendEmailTemplate
|
|||
public function render($hideDetails = false)
|
||||
{
|
||||
$View = new View();
|
||||
$View->autoLayout = false;
|
||||
$View->helpers = ['TextColour'];
|
||||
$View->loadHelpers();
|
||||
|
||||
|
|
|
@ -3247,6 +3247,7 @@ class Event extends AppModel
|
|||
$template->set('distributionLevels', $this->distributionLevels);
|
||||
$template->set('analysisLevels', $this->analysisLevels);
|
||||
$template->set('tlp', $this->getEmailSubjectMarkForEvent($event));
|
||||
$template->referenceId("event-alert|{$event['Event']['id']}");
|
||||
return $template;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue