aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-07-17 14:22:32 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-07-18 08:35:36 +0100
commit8c58acc4b9704ebf1bcc4981f1ff9184dc5d6eed (patch)
tree893d889e181b3923612b1ef87711731fafad4bfd
parent8abf4f67c94344dd190c02b86b34126834818635 (diff)
Spot email sending success, use on contact page.
-rw-r--r--perllib/FixMyStreet/App.pm9
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm5
2 files changed, 7 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 5575d915e..c1628d010 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -297,7 +297,7 @@ sub get_override {
=head2 send_email
- $email_sent = $c->send_email( 'email_template.txt', $extra_stash_values );
+ $success = $c->send_email( 'email_template.txt', $extra_stash_values );
Send an email by filling in the given template with values in the stash.
@@ -309,6 +309,8 @@ set those fields in the email if they are present.
If a 'from' is not specified then the default from the config is used.
+Returns the email on success, false on failure.
+
=cut
sub send_email {
@@ -353,14 +355,15 @@ sub send_email {
my $email = mySociety::Locale::in_gb_locale { FixMyStreet::Email::construct_email($data) };
+ my $result = 0;
try {
FixMyStreet::Email::Sender->send($email, { from => $sender });
+ $result = $email;
} catch {
my $error = $_ || 'unknown error';
$c->log->error("$error");
};
-
- return $email;
+ return $result;
}
=head2 uri_with
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index 5a077d8c3..e1eb64ba3 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -257,10 +257,7 @@ sub send_email : Private {
$params->{from} = $from;
}
- $c->send_email('contact.txt', $params);
-
- # above is always succesful :(
- $c->stash->{success} = 1;
+ $c->stash->{success} = $c->send_email('contact.txt', $params);
return 1;
}