From 3d7f4c7c6d6c9c8b478d67ec7ef4fe69e30a2184 Mon Sep 17 00:00:00 2001 From: Marcus von Appen Date: Mon, 12 Sep 2016 17:33:42 +0100 Subject: Bug 1070122 - add option to send test email to Params page --- editparams.cgi | 14 ++++++++++++++ template/en/default/admin/params/editparams.html.tmpl | 3 +++ template/en/default/email/mta-test.txt.tmpl | 18 ++++++++++++++++++ template/en/default/global/messages.html.tmpl | 10 ++++++++++ 4 files changed, 45 insertions(+) create mode 100644 template/en/default/email/mta-test.txt.tmpl diff --git a/editparams.cgi b/editparams.cgi index 796d80d41..c91235c06 100755 --- a/editparams.cgi +++ b/editparams.cgi @@ -147,6 +147,20 @@ if ($action eq 'save' && $current_module) { delete_token($token); } +if ($cgi->param('save-and-test-mta-params') && + $cgi->request_method() eq "POST") +{ + my $message; + my $mail_template = Bugzilla->template_inner($user->setting('lang')); + $mail_template->process('email/mta-test.txt.tmpl', undef, \$message); + require Bugzilla::Mailer; + + # This will throw all sorts of useful errors if mail is not working + Bugzilla::Mailer::MessageToMTA($message); + + $vars->{'message'} = 'mta_param_tests_run'; +} + $vars->{'token'} = issue_session_token('edit_parameters'); $template->process("admin/params/editparams.html.tmpl", $vars) diff --git a/template/en/default/admin/params/editparams.html.tmpl b/template/en/default/admin/params/editparams.html.tmpl index 4e1946dd8..a8b272039 100644 --- a/template/en/default/admin/params/editparams.html.tmpl +++ b/template/en/default/admin/params/editparams.html.tmpl @@ -93,6 +93,9 @@ + [% IF panel.name == "mta" %] + + [% END %] [% END %] diff --git a/template/en/default/email/mta-test.txt.tmpl b/template/en/default/email/mta-test.txt.tmpl new file mode 100644 index 000000000..9add094b1 --- /dev/null +++ b/template/en/default/email/mta-test.txt.tmpl @@ -0,0 +1,18 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +Content-Type: text/plain +From: [% Param('mailfrom') %] +To: [% user.email %] +Subject: [% terms.Bugzilla %] Email System Test Message +X-Bugzilla-Type: admin + +Dear [% terms.Bugzilla %] administrator, + +This is a test email from your [% terms.Bugzilla %] system. If you can +read this, your [% terms.Bugzilla %] can send email. diff --git a/template/en/default/global/messages.html.tmpl b/template/en/default/global/messages.html.tmpl index 9f6464601..5db6aeb93 100644 --- a/template/en/default/global/messages.html.tmpl +++ b/template/en/default/global/messages.html.tmpl @@ -544,6 +544,16 @@ No changes made to milestone [% milestone.name FILTER html %]. [% END %] + [% ELSIF message_tag == "mta_param_tests_run" %] + [% title = "Parameters Updated And Test Email Sent" %] + [% IF param_changed.size > 0 %] + [% FOREACH param = param_changed %] + Changed [% param FILTER html %].
+ [% END %] +
+ [% END %] + Test mail sent to [% user.email %]. + [% ELSIF message_tag == "parameters_updated" %] [% title = "Parameters Updated" %] [% IF param_changed.size > 0 %] -- cgit v1.2.3-24-g4f1b