aboutsummaryrefslogtreecommitdiffstats
path: root/bin/handlemail
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-11-20 21:37:17 +0000
committerMatthew Somerville <matthew@mysociety.org>2015-12-02 17:41:42 +0000
commit23949e52f20020fa56cd54655a487ef97ebbc222 (patch)
treefd8a58a3b6df905851ecbed5d83919d7d9d88ed1 /bin/handlemail
parentd48de55d99bd55b28c5aa0fd9f095e9c918b52cb (diff)
Remove many uses of mySociety::Config.
Diffstat (limited to 'bin/handlemail')
-rwxr-xr-xbin/handlemail23
1 files changed, 11 insertions, 12 deletions
diff --git a/bin/handlemail b/bin/handlemail
index 5d4ac753c..597d08a5d 100755
--- a/bin/handlemail
+++ b/bin/handlemail
@@ -17,15 +17,14 @@ use strict;
use warnings;
require 5.8.0;
-# Horrible boilerplate to set up appropriate library paths.
-use FindBin;
-use lib "$FindBin::Bin/../perllib";
-use lib "$FindBin::Bin/../commonlib/perllib";
-
-use mySociety::Config;
BEGIN {
- mySociety::Config::set_file("$FindBin::Bin/../conf/general");
+ use File::Basename qw(dirname);
+ use File::Spec;
+ my $d = dirname(File::Spec->rel2abs($0));
+ require "$d/../setenv.pl";
}
+
+use FixMyStreet;
use mySociety::Email;
use mySociety::EmailUtil;
use mySociety::HandleMail;
@@ -40,7 +39,7 @@ my %data = mySociety::HandleMail::get_message();
if ($data{is_bounce_message}) {
#my $a = mySociety::HandleMail::get_bounce_recipient($data{message});
#my $token = mySociety::HandleMail::get_token($a,
- # 'fms-', mySociety::Config::get('EMAILDOMAIN')
+ # 'fms-', FixMyStreet->config('EMAILDOMAIN')
#);
#exit(0) if $token eq 'DO-NOT-REPLY'; # A bounce we don't care about
exit(0); # drop all other bounces currently
@@ -48,13 +47,13 @@ if ($data{is_bounce_message}) {
# Not a bounce, send an automatic response
my $template = 'reply-autoresponse';
-open FP, "$FindBin::Bin/../templates/email/default/$template" or exit 75;
-$template = join('', <FP>);
-close FP;
+my $fp = FixMyStreet->path_to("templates", "email", "default", $template)->open or exit 75;
+$template = join('', <$fp>);
+$fp->close;
# We generate this as a bounce.
my $mail = mySociety::Email::construct_email({
- From => [ mySociety::Config::get('CONTACT_EMAIL'), 'FixMyStreet' ],
+ From => [ FixMyStreet->config('CONTACT_EMAIL'), 'FixMyStreet' ],
To => $data{return_path},
_template_ => $template,
_parameters_ => { },