diff --git a/CHANGELOG.md b/CHANGELOG.md index 53435a4..905731e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v3.1.3 +## 07/19/2021 + +1. [](#improved) + * Pass page variable to processed forms [#141](https://github.com/getgrav/grav-plugin-email/pull/141) + * Email configuration available to templates [#152](https://github.com/getgrav/grav-plugin-email/pull/152) + * New Event after eMail was sent [#151](https://github.com/getgrav/grav-plugin-email/pull/151) + # v3.1.2 ## 04/06/2021 diff --git a/blueprints.yaml b/blueprints.yaml index e331972..04100ad 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Email slug: email type: plugin -version: 3.1.2 +version: 3.1.3 testing: false description: Enables the emailing system for Grav icon: envelope diff --git a/classes/Email.php b/classes/Email.php index dfcb698..9891f9f 100644 --- a/classes/Email.php +++ b/classes/Email.php @@ -171,6 +171,11 @@ public function buildMessage(array $params, array $vars = []) throw new \RuntimeException($language->translate('PLUGIN_EMAIL.PLEASE_CONFIGURE_A_FROM_ADDRESS')); } + // make email configuration available to templates + $vars += [ + 'email' => $params, + ]; + // Process parameters. foreach ($params as $key => $value) { switch ($key) { diff --git a/email.php b/email.php index cc86050..93e2b1c 100644 --- a/email.php +++ b/email.php @@ -91,7 +91,8 @@ public function onFormProcessed(Event $event) case 'email': // Prepare Twig variables $vars = array( - 'form' => $form + 'form' => $form, + 'page' => $this->grav['page'] ); // Copy files now, we need those. @@ -164,6 +165,9 @@ protected function sendFormEmail($form, $params, $vars) // Send e-mail $this->email->send($message); + + //fire event after eMail was sent + $this->grav->fireEvent('onEmailSent', new Event(['message' => $message, 'params' => $params, 'form' => $form])); } protected function isAssocArray(array $arr)