Improved detection of auto generated emails / prevent auto responder.
This commit is contained in:
parent
44a5b9861f
commit
570e3c981a
3 changed files with 44 additions and 2 deletions
|
@ -32,8 +32,8 @@ module Channel::EmailBuild
|
||||||
attr['X-Auto-Response-Suppress'] = 'All'
|
attr['X-Auto-Response-Suppress'] = 'All'
|
||||||
end
|
end
|
||||||
|
|
||||||
#attr['X-Powered-BY'] = 'Zammad - Support/Helpdesk (http://www.zammad.org/)'
|
attr['X-Powered-By'] = 'Zammad - Helpdesk/Support (https://zammad.org/)'
|
||||||
attr['X-Mailer'] = 'Zammad Mail Service (1.x)'
|
attr['X-Mailer'] = 'Zammad Mail Service'
|
||||||
|
|
||||||
# set headers
|
# set headers
|
||||||
attr.each do |key, value|
|
attr.each do |key, value|
|
||||||
|
|
|
@ -14,11 +14,20 @@ module Channel::Filter::AutoResponseCheck
|
||||||
mail[ 'x-zammad-article-preferences'.to_sym ]['send-auto-response'] = false
|
mail[ 'x-zammad-article-preferences'.to_sym ]['send-auto-response'] = false
|
||||||
mail[ 'x-zammad-article-preferences'.to_sym ]['is-auto-response'] = true
|
mail[ 'x-zammad-article-preferences'.to_sym ]['is-auto-response'] = true
|
||||||
|
|
||||||
|
# do not send an auto respondse if one of the following headers exists
|
||||||
|
return if mail[ 'list-unsubscribe'.to_sym ] && mail[ 'list-unsubscribe'.to_sym ] =~ /.../
|
||||||
return if mail[ 'x-loop'.to_sym ] && mail[ 'x-loop'.to_sym ] =~ /(yes|true)/i
|
return if mail[ 'x-loop'.to_sym ] && mail[ 'x-loop'.to_sym ] =~ /(yes|true)/i
|
||||||
return if mail[ 'precedence'.to_sym ] && mail[ 'precedence'.to_sym ] =~ /(bulk|list|junk)/i
|
return if mail[ 'precedence'.to_sym ] && mail[ 'precedence'.to_sym ] =~ /(bulk|list|junk)/i
|
||||||
return if mail[ 'auto-submitted'.to_sym ] && mail[ 'auto-submitted'.to_sym ] =~ /auto-(generated|replied)/i
|
return if mail[ 'auto-submitted'.to_sym ] && mail[ 'auto-submitted'.to_sym ] =~ /auto-(generated|replied)/i
|
||||||
return if mail[ 'x-auto-response-suppress'.to_sym ] && mail[ 'x-auto-response-suppress'.to_sym ] =~ /all/i
|
return if mail[ 'x-auto-response-suppress'.to_sym ] && mail[ 'x-auto-response-suppress'.to_sym ] =~ /all/i
|
||||||
|
|
||||||
|
# do not send an auto respondse if sender is system it self
|
||||||
|
message_id = mail[ 'message_id'.to_sym ]
|
||||||
|
if message_id
|
||||||
|
fqdn = Setting.get('fqdn')
|
||||||
|
return if message_id =~ /@#{Regexp.quote(fqdn)}/i
|
||||||
|
end
|
||||||
|
|
||||||
mail[ 'x-zammad-send-auto-response'.to_sym ] = true
|
mail[ 'x-zammad-send-auto-response'.to_sym ] = true
|
||||||
mail[ 'x-zammad-is-auto-response'.to_sym ] = false
|
mail[ 'x-zammad-is-auto-response'.to_sym ] = false
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,39 @@ Some Text"
|
||||||
Scheduler.worker(true)
|
Scheduler.worker(true)
|
||||||
assert_equal(1, article_p.ticket.articles.count)
|
assert_equal(1, article_p.ticket.articles.count)
|
||||||
|
|
||||||
|
email_raw_string = "From: me@example.com
|
||||||
|
To: customer@example.com
|
||||||
|
Subject: some new subject
|
||||||
|
List-Unsubscribe: <mailto:somebody@example.com>
|
||||||
|
|
||||||
|
Some Text"
|
||||||
|
|
||||||
|
fqdn = Setting.get('fqdn')
|
||||||
|
email_raw_string = "From: me@example.com
|
||||||
|
To: customer@example.com
|
||||||
|
Subject: some new subject
|
||||||
|
Message-ID: <1234@#{fqdn}>
|
||||||
|
|
||||||
|
Some Text"
|
||||||
|
|
||||||
|
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
|
||||||
|
Scheduler.worker(true)
|
||||||
|
assert_equal(1, article_p.ticket.articles.count)
|
||||||
|
|
||||||
|
fqdn = Setting.get('fqdn')
|
||||||
|
email_raw_string = "From: me@example.com
|
||||||
|
To: customer@example.com
|
||||||
|
Subject: some new subject
|
||||||
|
Message-ID: <1234@not_matching.#{fqdn}>
|
||||||
|
|
||||||
|
Some Text"
|
||||||
|
|
||||||
|
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
|
||||||
|
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
|
||||||
|
Scheduler.worker(true)
|
||||||
|
assert_equal(2, article_p.ticket.articles.count)
|
||||||
|
|
||||||
email_raw_string = "Return-Path: <XX@XX.XX>
|
email_raw_string = "Return-Path: <XX@XX.XX>
|
||||||
X-Original-To: sales@znuny.com
|
X-Original-To: sales@znuny.com
|
||||||
Received: from mail-qk0-f170.example.com (mail-qk0-f170.example.com [209.1.1.1])
|
Received: from mail-qk0-f170.example.com (mail-qk0-f170.example.com [209.1.1.1])
|
||||||
|
|
Loading…
Reference in a new issue