From 95b7aebbda332a71108505891ba7a412563af17b Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 3 Nov 2021 18:49:44 +0200 Subject: [PATCH 1/2] Added second parameter to `Email::send()` to get failed recipients --- CHANGELOG.md | 6 ++++++ classes/Email.php | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 905731e..0aa7be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v3.1.4 +## mm/dd/2021 + +1. [](#improved) + * Added second parameter to `Email::send()` to get failed recipients + # v3.1.3 ## 07/19/2021 diff --git a/classes/Email.php b/classes/Email.php index 9891f9f..689a7cd 100644 --- a/classes/Email.php +++ b/classes/Email.php @@ -101,13 +101,14 @@ public function image($data = null, $filename = null, $contentType = null) * Send email. * * @param \Swift_Message $message + * @param array|null $failedRecipients * @return int */ - public function send($message) + public function send($message, &$failedRecipients = null) { $mailer = $this->getMailer(); - $result = $mailer ? $mailer->send($message) : 0; + $result = $mailer ? $mailer->send($message, $failedRecipients) : 0; // Check if emails and debugging are both enabled. if ($mailer && $this->debug()) { @@ -181,7 +182,11 @@ public function buildMessage(array $params, array $vars = []) switch ($key) { case 'body': if (is_string($value)) { - $body = $twig->processString($value, $vars); + if (strpos($value, '{{') !== false || strpos($value, '{%') !== false) { + $body = $twig->processString($value, $vars); + } else { + $body = $value; + } if ($params['process_markdown'] && $params['content_type'] === 'text/html') { $parsedown = new Parsedown(); @@ -189,16 +194,14 @@ public function buildMessage(array $params, array $vars = []) } if ($params['template']) { - $vars = array_merge($vars, ['content' => $body]); - $body = $twig->processTemplate($params['template'], $vars); + $body = $twig->processTemplate($params['template'], ['content' => $body] + $vars); } $content_type = !empty($params['content_type']) ? $twig->processString($params['content_type'], $vars) : null; $charset = !empty($params['charset']) ? $twig->processString($params['charset'], $vars) : null; $message->setBody($body, $content_type, $charset); - } - elseif (is_array($value)) { + } elseif (is_array($value)) { foreach ($value as $body_part) { $body_part += [ 'charset' => $params['charset'], @@ -213,8 +216,7 @@ public function buildMessage(array $params, array $vars = []) } if (isset($body_part['template'])) { - $vars = array_merge($vars, ['content' => $body]); - $body = $twig->processTemplate($body_part['template'], $vars); + $body = $twig->processTemplate($body_part['template'], ['content' => $body] + $vars); } $content_type = !empty($body_part['content_type']) ? $twig->processString($body_part['content_type'], $vars) : null; From bebb2f1c947bc506568905b438153d3e76fb8253 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 16 Nov 2021 10:27:41 -0700 Subject: [PATCH 2/2] prepare for release --- CHANGELOG.md | 2 +- blueprints.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa7be8..455520e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v3.1.4 -## mm/dd/2021 +## 11/16/2021 1. [](#improved) * Added second parameter to `Email::send()` to get failed recipients diff --git a/blueprints.yaml b/blueprints.yaml index 04100ad..483e3d5 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Email slug: email type: plugin -version: 3.1.3 +version: 3.1.4 testing: false description: Enables the emailing system for Grav icon: envelope