##// END OF EJS Templates
Don't abort processing of emails when an email triggers a parsing exception (#16122)....
Jean-Philippe Lang -
r12720:ddcad64aa28e
parent child
Show More
@@ -46,6 +46,14 class MailHandler < ActionMailer::Base
46 46 super(email)
47 47 end
48 48
49 # Receives an email and rescues any exception
50 def self.safe_receive(*args)
51 receive(*args)
52 rescue => e
53 logger.error "An unexpected error occurred when receiving email: #{e.message}" if logger
54 return false
55 end
56
49 57 # Extracts MailHandler options from environment variables
50 58 # Use when receiving emails with rake tasks
51 59 def self.extract_options_from_env(env)
@@ -32,7 +32,7 module Redmine
32 32 imap.uid_search(['NOT', 'SEEN']).each do |uid|
33 33 msg = imap.uid_fetch(uid,'RFC822')[0].attr['RFC822']
34 34 logger.debug "Receiving message #{uid}" if logger && logger.debug?
35 if MailHandler.receive(msg, options)
35 if MailHandler.safe_receive(msg, options)
36 36 logger.debug "Message #{uid} successfully received" if logger && logger.debug?
37 37 if imap_options[:move_on_success]
38 38 imap.uid_copy(uid, imap_options[:move_on_success])
@@ -36,7 +36,7 module Redmine
36 36 pop_session.each_mail do |msg|
37 37 message = msg.pop
38 38 message_id = (message =~ /^Message-I[dD]: (.*)/ ? $1 : '').strip
39 if MailHandler.receive(message, options)
39 if MailHandler.safe_receive(message, options)
40 40 msg.delete
41 41 logger.debug "--> Message #{message_id} processed and deleted from the server" if logger && logger.debug?
42 42 else
General Comments 0
You need to be logged in to leave comments. Login now