Class: Mailman::MessageProcessor
- Inherits:
-
Object
- Object
- Mailman::MessageProcessor
- Defined in:
- lib/mailman/message_processor.rb
Overview
Turns a raw email into a Mail::Message
and passes it to the router.
Instance Method Summary collapse
-
#initialize(options) ⇒ MessageProcessor
constructor
A new instance of MessageProcessor.
-
#process(message) ⇒ Object
Converts a raw email into a
Mail::Message
instance, and passes it to the router. -
#process_maildir_message(message) ⇒ Object
Processes a
Maildir::Message
instance.
Constructor Details
#initialize(options) ⇒ MessageProcessor
Returns a new instance of MessageProcessor.
8 9 10 11 |
# File 'lib/mailman/message_processor.rb', line 8 def initialize() @router = [:router] @config = [:config] end |
Instance Method Details
#process(message) ⇒ Object
Converts a raw email into a Mail::Message
instance, and passes it to the router.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mailman/message_processor.rb', line 16 def process() mail = Mail.new() from = mail.from.nil? ? "unknown" : mail.from.first Mailman.logger.info "Got new message from '#{from}' with subject '#{mail.subject}'." # Run any middlewares before routing the message @config.middleware.run(mail) do @router.route(mail) end end |
#process_maildir_message(message) ⇒ Object
Processes a Maildir::Message
instance.
28 29 30 31 32 33 34 35 36 |
# File 'lib/mailman/message_processor.rb', line 28 def () begin process(.data) .process # move message to cur .seen! rescue StandardError => error Mailman.logger.error "Error encountered processing message: #{.inspect}\n #{error.class.to_s}: #{error.}\n #{error.backtrace.join("\n")}" end end |