monolog-bundle icon indicating copy to clipboard operation
monolog-bundle copied to clipboard

Email Encryption

Open raziel057 opened this issue 2 years ago • 0 comments

Hello,

What do you think about providing an option to encrypt emails when using the Symfony MailerHandler? As described here https://symfony.com/doc/current/mailer.html#encrypting-messages

It's often very useful to be notified by email about errors in an application as described here: https://symfony.com/doc/current/logging/monolog_email.html but in the same time sending emails with technical / sensible information can be seen as security risk and pointed by auditors.

It seems to me it would be possible to add an encrypt_certif option to provide a crt that can be used by the handler to encrypt the emails.

If the encrypt_certif is a valid certificate, it can be passed to the MailerHandler (monolog-bridge) and then used in the send method like this:

protected function send(string $content, array $records)
    {
        //$this->mailer->send($this->buildMessage($content, $records));
        $message = $this->buildMessage($content, $records);

        if ($this->certifEncrypt !== null) {
            $encrypter = new SMimeEncrypter($this->certifEncrypt);
            $this->mailer->send($encrypter->encrypt($message));
        } else {
            $this->mailer->send($message);
        }
    }

What do you think about this idea?

raziel057 avatar Aug 24 '22 11:08 raziel057