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') } data: { email_address: this.get('testEmailAddress') }
}).then(function () { }).then(function () {
self.set('sentTestEmail', true); self.set('sentTestEmail', true);
}).catch(function () { }, 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')); bootbox.alert(I18n.t('admin.email.test_error'));
}
}).finally(function() { }).finally(function() {
self.set('sendingEmail', false); self.set('sendingEmail', false);
}); });

View file

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

View file

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

View file

@ -1760,6 +1760,7 @@ en:
settings: "Settings" settings: "Settings"
all: "All" all: "All"
sending_test: "Sending test Email..." 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." 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" sent: "Sent"
skipped: "Skipped" skipped: "Skipped"