Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Oct 26, 2022
2 parents 3cc39e2 + 2e12044 commit a5b121f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v1.0.2
## 10/25/2022

1. [](#new)
* Throw validation exception if API token is missing or invalid
1. [](#bugfix)
* Fixed an issue with basic array style email addresses

# v1.0.1
## 09/27/2022

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: MailerSend
slug: mailersend
type: plugin
version: 1.0.1
version: 1.0.2
description: Send email with the MailerSend API
icon: paper-plane-o
author:
Expand Down
15 changes: 12 additions & 3 deletions mailersend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Composer\Autoload\ClassLoader;
use Grav\Common\Data\Data;
use Grav\Common\Data\ValidationException;
use Grav\Common\Plugin;
use Grav\Common\Utils;
use League\HTMLToMarkdown\HtmlConverter;
Expand Down Expand Up @@ -75,8 +76,6 @@ public function onFormProcessed(Event $event): void
$action = $event['action'];
$params = $event['params'];



if ($action === 'mailersend') {
$vars = new Data([
'form' => $form,
Expand All @@ -87,6 +86,16 @@ public function onFormProcessed(Event $event): void
$params = $this->processParams($params, $vars->toArray());

$api_token = $this->config->get('plugins.mailersend.api_token');
if (empty($api_token) || strlen($api_token) < 10) {
$message = "Invalid or missing Mailersend API token";
$this->grav->fireEvent('onFormValidationError', new Event([
'form' => $form,
'message' => $message
]));
$event->stopPropagation();
return;
}

$mailersend = new MailerSend(['api_key' => $api_token]);
$emailParams = new EmailParams();

Expand Down Expand Up @@ -168,7 +177,7 @@ protected function processRecipients(string $type, array $params)
$list[] = $this->createRecipient($recipient);
}
} else {
if (Utils::contains($recipients, ',')) {
if (is_string($recipients) && Utils::contains($recipients, ',')) {
$recipients = array_map('trim', explode(',', $recipients));
foreach ($recipients as $recipient) {
$list[] = $this->createRecipient($recipient);
Expand Down

0 comments on commit a5b121f

Please sign in to comment.