Ignore emails with "Auto-Submitted: auto-*" header (#11338).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9924 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d4dd35a78c
commit
232edc6237
|
@ -50,8 +50,8 @@ class MailHandler < ActionMailer::Base
|
|||
|
||||
cattr_accessor :ignored_emails_headers
|
||||
@@ignored_emails_headers = {
|
||||
'X-Auto-Response-Suppress' => 'OOF',
|
||||
'Auto-Submitted' => 'auto-replied'
|
||||
'X-Auto-Response-Suppress' => 'oof',
|
||||
'Auto-Submitted' => /^auto-/
|
||||
}
|
||||
|
||||
# Processes incoming emails
|
||||
|
@ -69,13 +69,16 @@ class MailHandler < ActionMailer::Base
|
|||
# Ignore auto generated emails
|
||||
self.class.ignored_emails_headers.each do |key, ignored_value|
|
||||
value = email.header[key]
|
||||
if value && value.to_s.downcase == ignored_value.downcase
|
||||
if value
|
||||
value = value.to_s.downcase
|
||||
if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value
|
||||
if logger && logger.info
|
||||
logger.info "MailHandler: ignoring email with #{key}:#{value} header"
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
@user = User.find_by_mail(sender_email) if sender_email.present?
|
||||
if @user && !@user.active?
|
||||
if logger && logger.info
|
||||
|
|
|
@ -382,7 +382,8 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
[
|
||||
"X-Auto-Response-Suppress: OOF",
|
||||
"Auto-Submitted: auto-replied",
|
||||
"Auto-Submitted: Auto-Replied"
|
||||
"Auto-Submitted: Auto-Replied",
|
||||
"Auto-Submitted: auto-generated"
|
||||
].each do |header|
|
||||
raw = IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
raw = header + "\n" + raw
|
||||
|
|
Loading…
Reference in New Issue