aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-05-12 12:43:04 +0100
committerGareth Rees <gareth@mysociety.org>2015-05-12 12:43:04 +0100
commit245607091397ec767272f4bd99dc5f243d6d1f42 (patch)
treeab030589069b9c84de078f388f4231baac281a56 /app/models/info_request.rb
parente2e393db294c5a7144a65f97e86e51606c42d820 (diff)
Discard rejected responses with malformed From:2422-incoming-message-spam
Stops the RequestMailer trying to send a stopped_responses mail if the To: address can’t be parsed from the incoming message. ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index f75d43010..d46dc63ae 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -461,7 +461,11 @@ public
# If its not allowing responses, handle the message
if !allow
if self.handle_rejected_responses == 'bounce'
- RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external?
+ if MailHandler.get_from_address(email).nil?
+ log_event('response', :rejected_reason => _('Could not return the message to the sender because there is no "From" address'))
+ else
+ RequestMailer.stopped_responses(self, email, raw_email_data).deliver if !is_external?
+ end
elsif self.handle_rejected_responses == 'holding_pen'
InfoRequest.holding_pen_request.receive(email, raw_email_data, false, reason)
elsif self.handle_rejected_responses == 'blackhole'