diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index dcd85d535f..a65dd3270a 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -136,28 +136,6 @@ class SettingsController extends Controller ->with('section', 'Pre-Flight Check'); } - /** - * Test the email configuration - * - * @author [A. Gianotto] [] - * @since [v3.0] - * @return Redirect - */ - public function ajaxTestEmail() - { - - try { - Mail::send('emails.test', [], function ($m) { - $m->to(config('mail.from.address'), config('mail.from.name')); - $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name')); - $m->subject(trans('mail.test_email')); - }); - return 'success'; - } catch (Exception $e) { - return 'error'; - } - - } /** * Save the first admin user from Setup. @@ -1024,4 +1002,28 @@ class SettingsController extends Controller public function api() { return view('settings.api'); } + + + + /** + * Test the email configuration + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return Redirect + */ + public function ajaxTestEmail() + { + try { + Mail::send('emails.test', [], function ($m) { + $m->to(config('mail.from.address'), config('mail.from.name')); + $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name')); + $m->subject(trans('mail.test_email')); + }); + return response()->json(['message' => 'Mail sent! '], 200); + } catch (Exception $e) { + return response()->json(['message' => $e->getMessage()], 500); + } + + } } diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index bd5584109f..d33691b84a 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -178,6 +178,27 @@ + +
+
+ {{ Form::label('login_note', 'Test Mail') }} +
+
+ + Send Test + + + +
+
+
+
+
+

This will attempt to send a test mail to {{ config('mail.reply_to.address') }}.

+
+ +
+ - {{Form::close()}} + {{ Form::close() }} @stop @@ -208,5 +229,50 @@ }).on('ifUnchecked', function(){ $('#auto_increment_prefix').prop('disabled', true); }); + + + // Test Mail + $("#mailtest").click(function(){ + $("#mailtestrow").removeClass('text-success'); + $("#mailtestrow").removeClass('text-danger'); + $("#mailteststatus").html(''); + $("#mailtesticon").html(' Sending Test Email...'); + $.ajax({ + url: '{{ route('settings.mailtest') }}', + type: 'POST', + headers: { + "X-Requested-With": 'XMLHttpRequest', + "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content') + }, + data: {}, + dataType: 'json', + + success: function (data) { + $("#mailtesticon").html(''); + $("#mailteststatus").html(''); + $('#mailteststatus-error').html(''); + $("#mailteststatus").removeClass('text-danger'); + $("#mailteststatus").addClass('text-success'); + $("#mailteststatus").html(' Mail sent!'); + }, + + error: function (data) { + + $("#mailtesticon").html(''); + $("#mailteststatus").html(''); + $('#mailteststatus-error').html(''); + $("#mailteststatus").removeClass('text-success'); + $("#mailteststatus").addClass('text-danger'); + $("#mailtesticon").html(''); + $('#mailteststatus').html('Mail could not be sent.'); + $('#mailteststatus-error').html('Error: ' + data.responseJSON.messages); + + } + + + }); + }); + + @stop