Sorry, we don't support your browser.  Install a modern browser

A hook "email.sending:before" would be peachy!

I’m trying to find the least intrussive way to create a plugin to encrypt outgoing emails. Ideally it’d be something like this:


<?php
    Kirby::plugin('stairjoke/encrypt-outgoing-emails', [
        'hooks' => [
            'email.sending:before' => function (&$email) {
                $email['body'] = encrypt($email['body']);
            }
        ]
    ]);
?>

But there are no email hooks whatsoever available. At the moment it looks like I have to write my own transport Class to hook into the sending process. A hook “email.sending:before” would be peachy!

7 months ago

I think you need exactly beforeSend callback:
https://getkirby.com/docs/guide/emails#access-phpmailer

7 months ago

That certainly works for forms etc, thank you! That is already a great improvement.

I’d like to add encryption to all outgoing mails, including those sent by the system itself though.

7 months ago