Don't abort processing of emails when an email triggers a parsing exception (#16122).
git-svn-id: http://svn.redmine.org/redmine/trunk@12995 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
429210f03f
commit
ddcad64aa2
|
@ -46,6 +46,14 @@ class MailHandler < ActionMailer::Base
|
|||
super(email)
|
||||
end
|
||||
|
||||
# Receives an email and rescues any exception
|
||||
def self.safe_receive(*args)
|
||||
receive(*args)
|
||||
rescue => e
|
||||
logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
|
||||
return false
|
||||
end
|
||||
|
||||
# Extracts MailHandler options from environment variables
|
||||
# Use when receiving emails with rake tasks
|
||||
def self.extract_options_from_env(env)
|
||||
|
|
|
@ -32,7 +32,7 @@ module Redmine
|
|||
imap.uid_search(['NOT', 'SEEN']).each do |uid|
|
||||
msg = imap.uid_fetch(uid,'RFC822')[0].attr['RFC822']
|
||||
logger.debug "Receiving message #{uid}" if logger && logger.debug?
|
||||
if MailHandler.receive(msg, options)
|
||||
if MailHandler.safe_receive(msg, options)
|
||||
logger.debug "Message #{uid} successfully received" if logger && logger.debug?
|
||||
if imap_options[:move_on_success]
|
||||
imap.uid_copy(uid, imap_options[:move_on_success])
|
||||
|
|
|
@ -36,7 +36,7 @@ module Redmine
|
|||
pop_session.each_mail do |msg|
|
||||
message = msg.pop
|
||||
message_id = (message =~ /^Message-I[dD]: (.*)/ ? $1 : '').strip
|
||||
if MailHandler.receive(message, options)
|
||||
if MailHandler.safe_receive(message, options)
|
||||
msg.delete
|
||||
logger.debug "--> Message #{message_id} processed and deleted from the server" if logger && logger.debug?
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue