aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-11-23 13:39:48 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-11-23 18:00:52 +0000
commitd191b211cc25c60d2a1464711ff4212f4d4a5e6e (patch)
treee510e580ab8336b3b8a819095b8456d36819c5cd /bin
parent755910d87c36c1ec4e6b8216cf50954fbd93b783 (diff)
Use standard email sending for handlemail.
The EmailUtil library expects "\n" line endings, otherwise it gets confused. It also doesn't handle a different SMTP port, and so on. We also make sure the return path is chomped.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/handlemail13
-rwxr-xr-xbin/handlemail-support15
2 files changed, 15 insertions, 13 deletions
diff --git a/bin/handlemail b/bin/handlemail
index f85ad3e65..5a4d6e1f2 100755
--- a/bin/handlemail
+++ b/bin/handlemail
@@ -22,7 +22,6 @@ BEGIN {
use FixMyStreet;
use FixMyStreet::DB;
use FixMyStreet::Email;
-use mySociety::EmailUtil;
use mySociety::HandleMail;
use mySociety::SystemMisc qw(print_log);
@@ -167,12 +166,13 @@ sub handle_non_bounce_to_null_address {
$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' ],
- To => $data{return_path},
+ To => $rp,
_body_ => $template,
});
- send_mail($mail->as_string, $data{return_path});
+ send_mail($mail, $rp);
}
sub forward_on_to {
@@ -182,9 +182,10 @@ sub forward_on_to {
}
sub send_mail {
- my ($text, $recipient) = @_;
- if (mySociety::EmailUtil::EMAIL_SUCCESS
- != mySociety::EmailUtil::send_email($text, '<>', $recipient)) {
+ my ($email, $recipient) = @_;
+ unless (FixMyStreet::Email::Sender->try_to_send(
+ $email, { from => '<>', to => $recipient }
+ )) {
exit(75);
}
}
diff --git a/bin/handlemail-support b/bin/handlemail-support
index 0ccde8ca7..76fcb4f4e 100755
--- a/bin/handlemail-support
+++ b/bin/handlemail-support
@@ -22,7 +22,6 @@ BEGIN {
}
use FixMyStreet;
-use mySociety::EmailUtil;
use mySociety::HandleMail;
my %data = mySociety::HandleMail::get_message();
@@ -33,12 +32,14 @@ forward_on();
sub forward_on {
my ($l, $d) = split /\@/, FixMyStreet->config('CONTACT_EMAIL');
- if (mySociety::EmailUtil::EMAIL_SUCCESS
- != mySociety::EmailUtil::send_email(
- join("\n", @{$data{lines}}) . "\n",
- $data{return_path},
- join('@', join('_deli', $l, 'very'), $d)
- )) {
+ my ($rp) = $data{return_path} =~ /^\s*<(.*)>\s*$/;
+ unless (FixMyStreet::Email::Sender->try_to_send(
+ join("\n", @{$data{lines}}) . "\n",
+ {
+ from => $rp,
+ to => join('@', join('_deli', $l, 'very'), $d)
+ }
+ )) {
exit 75;
}
exit 0;