aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Contact.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-25 17:44:37 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-25 17:44:37 +0100
commit09a64afec4e023a184de075df3780c8b525b6066 (patch)
treecad6484a2c8d074251960cd781139d28e68bb2ef /perllib/FixMyStreet/App/Controller/Contact.pm
parentbbe4d5975fddfc731b0177119bf4cda401d41d97 (diff)
use c->send_email on contact page and add more tests
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Contact.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm47
1 files changed, 15 insertions, 32 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index a3e397022..0e6e60944 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -181,14 +181,6 @@ sub prepare_params_for_email : Private {
);
}
- my $postfix = '[ Sent by contact.cgi on ' .
- $ENV{'HTTP_HOST'} . '. ' .
- "IP address " . $ENV{'REMOTE_ADDR'} .
- ($ENV{'HTTP_X_FORWARDED_FOR'} ? ' (forwarded from '.$ENV{'HTTP_X_FORWARDED_FOR'}.')' : '') . '. ' .
- ' ]';
-
- $c->stash->{message} .= "\n\n$postfix";
-
return 1;
}
@@ -227,30 +219,21 @@ sub send_email : Private {
my $recipient = $c->cobrand->contact_email();
my $recipient_name = $c->cobrand->contact_name();
- my $email = mySociety::Email::construct_email(
- {
- _body_ => $c->stash->{message},
- From => [ $c->stash->{em}, $c->stash->{form_name} ],
- To => [ [ $recipient, _($recipient_name) ] ],
- Subject => 'FMS message: ' . $c->stash->{subject},
- 'Message-ID' => sprintf(
- '<contact-%s-%s@mysociety.org>',
- time(), unpack( 'h*', random_bytes( 5, 1 ) )
- ),
- }
- );
-
- # FIXME: do something more sensible here
- if ( FixMyStreet->test_mode ) {
- $c->stash->{success} = 1;
- } else {
- my $result =
- mySociety::EmailUtil::send_email( $email, $c->stash->{em}, $recipient );
-
- if ( $result == mySociety::EmailUtil::EMAIL_SUCCESS ) {
- $c->stash->{success} = 1;
- }
- }
+ $c->stash->{host} = $c->req->header('HOST');
+ $c->stash->{ip} = $c->req->address;
+ $c->stash->{ip} .=
+ $c->req->header('X-Forwarded-For')
+ ? ' ( forwarded from ' . $c->req->header('X-Forwarded-For') . ' )'
+ : '';
+
+ $c->send_email( 'contact.txt', {
+ to => [ [ $recipient, _($recipient_name) ] ],
+ from => [ $c->stash->{em}, $c->stash->{form_name} ],
+ subject => 'FMS message: ' . $c->stash->{subject},
+ });
+
+ # above is always succesful :(
+ $c->stash->{success} = 1;
return 1;
}