From 9c7addb2cee6f56e832be7848be3d53e8d6b4da3 Mon Sep 17 00:00:00 2001 From: Dom Stubbs Date: Mon, 21 Oct 2019 14:37:42 +0100 Subject: [PATCH] Support env variables for toEmail setting Fixes #166 --- src/Mailer.php | 3 ++- src/templates/_settings.twig | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mailer.php b/src/Mailer.php index 3b38120..a9a1234 100644 --- a/src/Mailer.php +++ b/src/Mailer.php @@ -95,7 +95,8 @@ public function send(Submission $submission, bool $runValidation = true): bool } // Grab any "to" emails set in the plugin settings. - $toEmails = is_string($settings->toEmail) ? StringHelper::split($settings->toEmail) : $settings->toEmail; + $toEmails = Craft::parseEnv($settings->toEmail); + $toEmails = is_string($toEmails) ? StringHelper::split($toEmails) : $toEmails; // Fire a 'beforeSend' event $event = new SendEvent([ diff --git a/src/templates/_settings.twig b/src/templates/_settings.twig index 669c2c3..3e1fa7a 100644 --- a/src/templates/_settings.twig +++ b/src/templates/_settings.twig @@ -10,7 +10,7 @@ {% from _self import configWarning %} -{{ forms.textField({ +{{ forms.autosuggestField({ first: true, label: "To Email"|t('contact-form'), required: true, @@ -18,6 +18,7 @@ name: 'toEmail', instructions: "The email address(es) that the contact form will send to. Separate multiple email addresses with commas."|t('contact-form'), value: settings.toEmail, + suggestEnvVars: true, autofocus: true, disabled: 'toEmail' in overrides, warning: 'toEmail' in overrides ? configWarning('toEmail'),