Fake sending the test email if the app is in demo mode

This commit is contained in:
snipe 2017-10-19 08:33:46 -07:00
parent 2b826c3adc
commit 7153013fb0
2 changed files with 18 additions and 10 deletions

View file

@ -170,16 +170,19 @@ class SettingsController extends Controller
*/
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);
if (!config('app.lock_passwords')) {
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 to '.config('mail.from.address')], 200);
} catch (Exception $e) {
return response()->json(['message' => $e->getMessage()], 500);
}
}
return response()->json(['message' => 'Mail would have been sent, but this application is in demo mode! '], 200);
}

View file

@ -250,12 +250,17 @@
dataType: 'json',
success: function (data) {
console.dir(data);
$("#mailtesticon").html('');
$("#mailteststatus").html('');
$('#mailteststatus-error').html('');
$("#mailteststatus").removeClass('text-danger');
$("#mailteststatus").addClass('text-success');
$("#mailteststatus").html('<i class="fa fa-check text-success"></i> Mail sent!');
if (data.message) {
$("#mailteststatus").html('<i class="fa fa-check text-success"></i> ' + data.message);
} else {
$("#mailteststatus").html('<i class="fa fa-check text-success"></i> Mail sent!');
}
},
error: function (data) {