FEATURE: show exact error for test email

This commit is contained in:
Arpit Jalan 2014-11-19 21:19:12 +05:30
parent a211f542f5
commit c84b51d4ae
4 changed files with 13 additions and 5 deletions

View file

@ -36,8 +36,12 @@ export default DiscourseController.extend({
data: { email_address: this.get('testEmailAddress') }
}).then(function () {
self.set('sentTestEmail', true);
}).catch(function () {
bootbox.alert(I18n.t('admin.email.test_error'));
}, function(e) {
if (e.responseJSON && e.responseJSON.errors) {
bootbox.alert(I18n.t('admin.email.error', { server_error: e.responseJSON.errors[0] }));
} else {
bootbox.alert(I18n.t('admin.email.test_error'));
}
}).finally(function() {
self.set('sendingEmail', false);
});

View file

@ -9,8 +9,12 @@ class Admin::EmailController < Admin::AdminController
def test
params.require(:email_address)
Jobs::TestEmail.new.execute(to_address: params[:email_address])
render nothing: true
begin
Jobs::TestEmail.new.execute(to_address: params[:email_address])
render nothing: true
rescue => e
render json: {errors: [e.message]}, status: 422
end
end
def all

View file

@ -52,4 +52,3 @@ Discourse::Application.configure do
config.developer_emails = emails.split(",").map(&:strip)
end
end

View file

@ -1760,6 +1760,7 @@ en:
settings: "Settings"
all: "All"
sending_test: "Sending test Email..."
error: "<b>ERROR</b> - %{server_error}"
test_error: "There was a problem sending the test email. Please double-check your mail settings, verify that your host is not blocking mail connections, and try again."
sent: "Sent"
skipped: "Skipped"