Improved email processing - added error/timeout handling.
This commit is contained in:
parent
295e67cb6f
commit
a17137c4a5
1 changed files with 4 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
class Channel::EmailParser
|
class Channel::EmailParser
|
||||||
|
PROZESS_TIME_MAX = 180
|
||||||
EMAIL_REGEX = /.+@.+/.freeze
|
EMAIL_REGEX = /.+@.+/.freeze
|
||||||
RECIPIENT_FIELDS = %w[to cc delivered-to x-original-to envelope-to].freeze
|
RECIPIENT_FIELDS = %w[to cc delivered-to x-original-to envelope-to].freeze
|
||||||
SENDER_FIELDS = %w[from reply-to return-path sender].freeze
|
SENDER_FIELDS = %w[from reply-to return-path sender].freeze
|
||||||
|
@ -106,7 +107,9 @@ returns
|
||||||
|
|
||||||
def process(channel, msg, exception = true)
|
def process(channel, msg, exception = true)
|
||||||
|
|
||||||
|
Timeout.timeout(PROZESS_TIME_MAX) do
|
||||||
_process(channel, msg)
|
_process(channel, msg)
|
||||||
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
# store unprocessable email for bug reporting
|
# store unprocessable email for bug reporting
|
||||||
path = Rails.root.join('tmp', 'unprocessable_mail')
|
path = Rails.root.join('tmp', 'unprocessable_mail')
|
||||||
|
|
Loading…
Reference in a new issue