getgrav / grav-plugin-email

Grav Email Plugin
http://getgrav.org
MIT License
37 stars 29 forks source link

Event right before Mail is send #148

Closed stanschus closed 3 years ago

stanschus commented 3 years ago

Hi, I would like to suggest an additional Event that gets fired right before mail is finally sent:

protected function sendFormEmail($form, $params, $vars)
{
    //code before
    $this->grav->fireEvent('onBeforeFinalEmailSend', new Event(['message' => $message]));
    // Send e-mail
    $this->email->send($message);
}

Reason: I had to encrypt form data send through email. It's possible to use OpenPGP with Swiftmailer through Nightjar's SwiftSigner-CryptGPG, but the signer needs to be applied to the message object. I know it's a very rare use case, because openpgp needs to be installed serverside and apache/nginx/php-fpm user needs an valid keyring and so on, but it's a very small change ;) I guess through a few modifications it's also possible to sign mails - maybe this is a more common use case.

// EDIT: I already "wrote" a plugin implementing NightJar's SwiftSigner - I also like to provide it to the grav community if there is an Event Hook - otherwise my plugin is not very "plugable" ;)

thanks.

rhukster commented 3 years ago

How about a pull request for this?