Use config option to prevent sender based auto responses.

This commit is contained in:
Martin Edenhofer 2016-05-06 09:57:04 +02:00
parent 6fb9371302
commit 0a27ec38dd
3 changed files with 32 additions and 1 deletions

View file

@ -668,7 +668,14 @@ perform changes on ticket
next if user.email !~ /@/
# do not sent notifications to this recipients
next if user.email =~ /(mailer-daemon|postmaster|abuse|root)@.+?\..+?/i
send_no_auto_response_reg_exp = Setting.get('send_no_auto_response_reg_exp')
begin
next if user.email =~ /#{send_no_auto_response_reg_exp}/i
rescue => e
logger.error "ERROR: Invalid regex '#{send_no_auto_response_reg_exp}' in setting send_no_auto_response_reg_exp"
logger.error 'ERROR: ' + e.inspect
next if user.email =~ /(mailer-daemon|postmaster|abuse|root)@.+?\..+?/i
end
email = user.email.downcase.strip
next if recipient_already[email]

17
test/fixtures/ticket_trigger/mail3.box vendored Normal file
View file

@ -0,0 +1,17 @@
From: Abuse <abuse@example.com>
To: me@example.com
Content-Type: text/plain;
charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Subject: =?iso-8859-1?Q?aa=E4=F6=FC=DFad_asd?=
X-Universally-Unique-Identifier: d12c15d2-e6d6-4ccd-86c7-abc2c3d0a2a2
Date: Fri, 4 May 2012 14:01:03 +0200
Message-Id: <BC182994-03FA-4DC5-8202-98CBFACA0887-1@example.com>
Mime-Version: 1.0 (Apple Message framework v1257)
=E4=F6=FC=DF ad asd
-Martin
--
Old programmers never die. They just branch to a new address.

View file

@ -604,6 +604,13 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_equal('new', ticket_p.state.name)
assert_equal(1, ticket_p.articles.count)
# process mail with abuse@ (no auto response)
content = IO.binread('test/fixtures/ticket_trigger/mail3.box')
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, content)
assert_equal('new', ticket_p.state.name)
assert_equal(1, ticket_p.articles.count)
Trigger.destroy_all
end