From 61f3bedc481ef82140044174a124af9e24b0ae6d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 11 Jan 2016 13:07:41 +0200 Subject: [PATCH] Added check for mail config settings --- app/Ninja/Mailers/Mailer.php | 6 ++++++ resources/lang/en/texts.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php index d1aa10ec7c7e..b7c50bea8836 100644 --- a/app/Ninja/Mailers/Mailer.php +++ b/app/Ninja/Mailers/Mailer.php @@ -9,6 +9,12 @@ class Mailer { public function sendTo($toEmail, $fromEmail, $fromName, $subject, $view, $data = []) { + // check the username is set + if ( ! env('POSTMARK_API_TOKEN') && ! env('MAIL_USERNAME')) { + return trans('texts.invalid_mail_config'); + } + + // don't send emails to dummy addresses if (stristr($toEmail, '@example.com')) { return true; } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 10e253be27b0..ba7fb23d8a20 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1032,4 +1032,7 @@ return array( 'color_font_help' => 'Note: the primary color and fonts are also used in the client portal and custom email designs.', 'live_preview' => 'Live Preview', + 'invalid_mail_config' => 'Unable to send email, please check that the mail settings are correct.', + + ); \ No newline at end of file