diff options
-rwxr-xr-x | bin/handlemail | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/bin/handlemail b/bin/handlemail index 5a4d6e1f2..6cdc8fbd8 100755 --- a/bin/handlemail +++ b/bin/handlemail @@ -19,6 +19,7 @@ BEGIN { require "$d/../setenv.pl"; } +use Getopt::Long; use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::Email; @@ -29,6 +30,15 @@ use mySociety::SystemMisc qw(print_log); # messages being generated (only in response to non-bounce input, obviously). mySociety::SystemMisc::log_to_stderr(0); +my $cobrand = "default"; + +# Where to forward mail that should be looked at by a person, +# such as a permanent bounce for a report. +my $bouncemgr = FixMyStreet->config('CONTACT_EMAIL'); + +GetOptions ("cobrand=s" => \$cobrand, + "bouncemgr=s" => \$bouncemgr); + my %data = mySociety::HandleMail::get_message(); my @lines = @{$data{lines}}; my $token = get_envelope_token(); @@ -103,7 +113,7 @@ sub handle_permanent_bounce { $object->disable(); } elsif ($type eq 'report') { print_log('info', "Received bounce for report " . $object->id . ", forwarding to support"); - forward_on_to(FixMyStreet->config('CONTACT_EMAIL')); + forward_on_to($bouncemgr); } } @@ -135,7 +145,7 @@ sub handle_bounce_to_verp_address { handle_non_bounce_to_verp_address(); } elsif (!$info) { print_log('info', "Unparsed bounce received for $type " . $object->id . ", forwarding to support"); - forward_on_to(FixMyStreet->config('CONTACT_EMAIL')); + forward_on_to($bouncemgr); } else { print_log('info', "Ignoring bounce received for $type " . $object->id . $info); } @@ -144,7 +154,7 @@ sub handle_bounce_to_verp_address { sub handle_non_bounce_to_verp_address { if ($type eq 'alert' && !is_out_of_office()) { print_log('info', "Received non-bounce for alert " . $object->id . ", forwarding to support"); - forward_on_to(FixMyStreet->config('CONTACT_EMAIL')); + forward_on_to($bouncemgr); } elsif ($type eq 'report') { print_log('info', "Received non-bounce for report " . $object->id . ", forwarding to report creator"); forward_on_to($object->user->email); @@ -161,14 +171,15 @@ sub handle_non_bounce_to_null_address { # Send an automatic response print_log('info', "Received non-bounce to null address, auto-replying"); my $template = 'reply-autoresponse'; - my $fp = FixMyStreet->path_to("templates", "email", "default", $template)->open or exit 75; + my $fp = FixMyStreet->path_to("templates", "email", $cobrand, $template)->open or exit 75; $template = join('', <$fp>); $fp->close; # We generate this as a bounce. my ($rp) = $data{return_path} =~ /^\s*<(.*)>\s*$/; my $mail = FixMyStreet::Email::construct_email({ - From => [ FixMyStreet->config('CONTACT_EMAIL'), 'FixMyStreet' ], + From => [ FixMyStreet->config('CONTACT_EMAIL'), + FixMyStreet->config('CONTACT_NAME') ], To => $rp, _body_ => $template, }); |