aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2009-02-11 10:53:41 +0000
committermatthew <matthew>2009-02-11 10:53:41 +0000
commit4547e0b237debe1df4d3777edff40dda25f99ce3 (patch)
tree2970c0b5113b512c52ca01da5b6f7c92e11422d9
parent36d5dafe39198244ac4fb43b8baacef8d55da3cc (diff)
Handlemail support for FixMyStreet.
-rwxr-xr-xbin/handlemail69
-rw-r--r--templates/emails/alert-update3
-rw-r--r--templates/emails/reply-autoresponse22
3 files changed, 92 insertions, 2 deletions
diff --git a/bin/handlemail b/bin/handlemail
new file mode 100755
index 000000000..7aeef218d
--- /dev/null
+++ b/bin/handlemail
@@ -0,0 +1,69 @@
+#!/usr/bin/perl -w
+#
+# handlemail:
+# Handle an individual incoming mail message.
+#
+# This script should be invoked through the .forward mechanism. It processes
+# replies to non-reply emails and auto-replies accordingly. Could deal with
+# bounces at some point too.
+#
+# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+#
+
+my $rcsid = ''; $rcsid .= '$Id: handlemail,v 1.1 2009-02-11 10:53:41 matthew Exp $';
+
+use strict;
+require 5.8.0;
+
+# Horrible boilerplate to set up appropriate library paths.
+use FindBin;
+use lib "$FindBin::Bin/../perllib";
+use lib "$FindBin::Bin/../../perllib";
+
+use mySociety::Config;
+BEGIN {
+ mySociety::Config::set_file("$FindBin::Bin/../conf/general");
+}
+use mySociety::Email;
+use mySociety::EmailUtil;
+use mySociety::HandleMail;
+use mySociety::SystemMisc;
+
+# Don't print diagnostics to standard error, as this can result in bounce
+# messages being generated (only in response to non-bounce input, obviously).
+mySociety::SystemMisc::log_to_stderr(0);
+
+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')
+ #);
+ #exit(0) if $token eq 'DO-NOT-REPLY'; # A bounce we don't care about
+ exit(0); # drop all other bounces currently
+}
+
+# Not a bounce, send an automatic response
+my $template = 'reply-autoresponse';
+open FP, "$FindBin::Bin/../templates/emails/$template" or exit 75;
+$template = join('', <FP>);
+close FP;
+
+# We generate this as a bounce.
+my $mail = mySociety::Email::construct_email({
+ Sender => '<>',
+ From => [ mySociety::Config::get('CONTACT_EMAIL'), 'FixMyStreet' ],
+ To => $data{return_path},
+ _template_ => $template,
+ _parameters_ => { },
+});
+
+if (mySociety::EmailUtil::EMAIL_SUCCESS
+ != mySociety::EmailUtil::send_email($mail, '<>', $data{return_path})) {
+ exit(75);
+}
+
+exit(0);
+
diff --git a/templates/emails/alert-update b/templates/emails/alert-update
index 1f257b75a..f68ee55a4 100644
--- a/templates/emails/alert-update
+++ b/templates/emails/alert-update
@@ -7,8 +7,7 @@ The following updates have been left on this problem:
To view or reply to these updates, please visit the following URL:
<?=$values['problem_url']?>
-Replies to this email will go to the team behind FixMyStreet, *not*
-to anyone who left an update.
+You cannot contact anyone by replying to this email.
Yours,
The FixMyStreet team
diff --git a/templates/emails/reply-autoresponse b/templates/emails/reply-autoresponse
new file mode 100644
index 000000000..2add58fea
--- /dev/null
+++ b/templates/emails/reply-autoresponse
@@ -0,0 +1,22 @@
+Subject: Automatic reply to your message to FixMyStreet
+
+Hi,
+
+This is an automatic response to your email; your email has not been delivered.
+
+If you're replying to an email about a report update, please visit
+the URL given in the email in order to leave a reply.
+
+If you are trying to confirm something, such as a report or an email
+alert, please click the link in the email that we sent you, or, if
+you cannot click the link, copy and paste it into the address bar of
+your web browser.
+
+If you're trying to unsubscribe from an email alert, there is an
+unsubscribe link at the bottom of the email.
+
+If you have a question or comment about the site, please send your
+email to team@fixmystreet.com
+
+Yours,
+The FixMyStreet team