Git Product home page Git Product logo

mailman's Introduction

Mailman Build Status

Mailman is an incoming mail processing microframework (with POP3 and Maildir support), that works with Rails "out of the box".

require 'mailman'
Mailman::Application.run do
  to 'ticket-%id%@example.org' do

    Ticket.find(params[:id]).add_reply(message)
  end
end

See the User Guide for more information.

This project is no longer maintained

Installation

gem install mailman

Compatibility

Tested on Ruby 2.1, 2.0, 1.9.3, JRuby, and Rubinius.

Ruby < 2.0.0

In order to use this gem with ruby versions older then 2.0.0, you have to restrict the maildir gem to the latest supported version in your Gemfile:

gem 'maildir', '< 2.1.0'

Thanks

This project was originally sponsored by Ruby Summer of Code (2010), and mentored by Steven Soroka.

Copyright

Copyright (c) 2010-2013 Jonathan Rudenberg. See LICENSE for details.

mailman's People

Contributors

edslocomb avatar ekampf avatar faramund avatar halorgium avatar inbeom avatar ismaelga avatar jc00ke avatar johncant avatar jphastings avatar jsoref avatar kieranp avatar kjg avatar klortho avatar leifbladt avatar loe avatar loopj avatar malet avatar mic92 avatar mspanc avatar ndbroadbent avatar phildarnowsky avatar philtr avatar rstawarz avatar shingara avatar siuying avatar ssoroka avatar tastycode avatar titanous avatar waldher avatar wvengen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailman's Issues

Google 2-Step Authentication

Is there any way of supporting Google's 2-step auth at the moment? This is my current output...

Mailman v0.5.1 started
POP3 receiver enabled ([email_address]@pop.gmail.com).
Polling enabled. Checking every 10 seconds.
/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/net/pop.rb:1005:in `check_response_auth': -ERR [AUTH] Application-specific password required: http://support.google.com/accounts/bin/answer.py?answer=185833 (Net::POPAuthenticationError)

I've generated the password as described on http://support.google.com/accounts/bin/answer.py?answer=185833 but haven't figured out the best way of submitting it so far.

malformed messages choking mailman

I get the occasional e-mail with malformed headers that cause mailman to choke. Here is an example:

/pub/something/shared/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/multibyte/chars.rb:59:in `method_missing': undefined method `each' for "Bob Smith":String (NoMethodError)
    from /pub/something/shared/bundle/ruby/1.9.1/gems/mailman-0.4.0/lib/mailman/route/conditions.rb:8:in `match'

In this case the To header looked like this:

To: Bob Smith

Is there any way to rescue these kinds of errors?

Connection in Application#polling_loop should be closed on error

Hi

I've found out that connection in Application#polling_loop should be closed on error (https://github.com/titanous/mailman/blob/master/lib/mailman/application.rb#L136).

Otherwise mailman will try to connect again on next iteration of the polling loop.

It can crash the app as at least built-in ruby POP3 library throws an error on attempt to connect if you are already connected to the POP3 server.

Steps to reproduce:

  1. Create Mailman app that uses POP3 & polling
  2. Throw any SystemCallError in the message processing block (e.g. try to unlink non-existent file)
  3. Observe how mailman crashes at next interation of the loop in Application#polling_loop

params aren't cleared between runs

I've noticed that the params parameter that being passed to routes isn't cleared between runs. My case is that I have two routes, one with 2 params and the other with 3 params, and they both routed to the same class:

to 'p-%id%-%token%@%slug%.example.com', IncomingMail::NewPost #1st rule
to 'p-%id%@%slug%.example.com', IncomingMail::NewPost #2nd rule

If I have two messages received, where the first one is matched with the 1st rule and the 2nd with the 2nd rule, the token param will still be there.

I've fixed it in my branch of the 0.4.0 version by just adding @params.clear to the beginning of the Router#route method, but it can be also fixed by not using @params.merge! (and just assigning instead).

arikfr@dc0099f

I wasn't sure how/where to spec it, because the current Router specs don't seem cover the @params functionality. Should I spec it in the functional specs?

If you will give me some guidance on where to spec it, I will gladly spec it and make a pull request for the current version.

mailman crash when server contains mail with no "From" field

When processing email without a "From" field (such as todo task created by apple app), mailman crash:

/Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/message_processor.rb:17:in `process': undefined method `first' for nil:NilClass (NoMethodError)
    from /Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/receiver/pop3.rb:41:in `block in get_messages'
    from /Users/siuying/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/pop.rb:665:in `each'
    from /Users/siuying/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/pop.rb:665:in `each_mail'
    from /Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/receiver/pop3.rb:40:in `get_messages'
    from /Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/application.rb:58:in `block in run'
    from /Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/application.rb:55:in `loop'
    from /Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/application.rb:55:in `run'
    from /Users/siuying/.rvm/gems/ruby-1.9.3-p0/gems/mailman-0.4.0/lib/mailman/application.rb:7:in `run'

a sample crash email: https://gist.github.com/bee01b32ef42110a2ea4

Maildir poll interval setting

How can I change the default poll interval when using Maildir?

Earlier I used POP polling and had defined the interval to 5 seconds. Then I thought I should get rid of that delay in my service and configured my server to receive the emails so that I could process incoming messages immediately when they arrive. But now I can not find a way to make Mailman to check the Maildir more frequently than the default 60 seconds.

I tried:

Mailman.config.poll_interval = 1
Mailman.config.maildir = '~/Maildir'

With no luck.

Does not work with ActionMailer 3.1.0.rc5

When I try to route the message to an ActionMailer (3.1.0.rc5) object, I get the error:

actionmailer-3.1.0.rc5/lib/action_mailer/base.rb:455:in `method_missing': 
  private method `new' called for WidgetMailer:Class (NoMethodError)`

I routed it to a non-ActionMailer class and it worked just fine.

Mailman doesn't work with multipart/encoded mail (base64)

Mailman code:

to('[email protected]').from("%email%").body(/ID (\d+) (OK|NO)/) do
...
end

Mailman don't pass body conditions with encrypted email.

message.body:

--------_next_part_29038_621003437_3812
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: base64

SUQgNDIgT0sK0JLQsNGIINC3Gda3cdFvTLKf331FGC10YAgLSAwMDAwMjQw
NQrQlNCw0YLQsNCXdadsasaCw0LfQsCAtIDIxLjEwLjIwMTAK0JLRgNC10LzRj9CX
0LDQutCw0LfQsCAtIDAwOjAwCtCY0JTQl9Cw0LrQsNC30LAgLSA0MgrQotC10LvQ
tdGE0L7QvSAtICs3NDk1MDAwMDAwMArQn9Cw0YHRgdCw0LbQuNGA0JjQvNGPIC0g
QXZpdGEgQXZpdGEK0J/QsNGB0YHQsNC20LjRgNCi0LXQu9C10YTQvtC9IC0gQXZp
dGEK0KTQASDSADSAe0L/Qu9Cw0YLRiyAtINCR0YDQvtC90YwK0KLQuNC/0JfQ
sNC60LDQt9CwId2ccJDRjdGA0L7Qv9C+0YDRggrQktC40LTQl9Cw0LrQsNC30LAg
LSDQASDAS7RgNGCCtCb0L7Qs9C40L3QmtC+0L3RgtGA0LDQs9C10L3R
gtCwIC0gMTIzNDU2NzgK0J/QsNGA0L7Qu9GM0JrQvtC90YLRgNCw0LPQtdC90YLQ
sCAtIDEyMzQ1Njc4CkVNYWls0JTQu9GP0J/QvtC00YLQstC10YDQttC00LXQvdC4
0Y/Ql9Cw0LrQsNC30LAgLSBtYkB3Mncuc3UK0JDQtNGA0LXRgdCf0L7QtNCw0YfQ
uDrQnNC10YHRgtC+0J/QvtC00LDRh9C4IC0g0LPQvtGB0YLQuNC90LjRhtCwICLQ
kNCy0LjRgtCwIgrQkNC00YDQtdGB0J/QvtC10LfQtNC60Lg60JzQtdGB0YLQvtCf
0L7QtNCw0YfQuCAtINCU0L7QvNC+0LTQtdC00L7QstC+INCw0Y3RgNC+0L/QvtGA
0YIKCiDQv9GDSSADASDASD==

--------_next_part_29038_621003437_3812--

Specs fail on latest code version

I just cloned the repo, tried running specs and 5 of them failing. I suspect it has something to do with me having different gems than those that were used for development.

Gems installed:
$ gem list

*** LOCAL GEMS ***

activesupport (3.0.0)
bundler (1.0.15)
fssm (0.1.4)
i18n (0.4.1)
mail (2.2.6.1)
maildir (0.6.0)
mime-types (1.16)
mocha (0.9.12)
polyglot (0.3.1)
rspec (1.3.2)
treetop (1.4.8)

The output from the spec run:
$ rake spec
rake/gempackagetask is deprecated. Use rubygems/package_task instead

Mailman::Application

  • should route a message based on the from address
  • should route a message based on the from and to addresses
  • should route a message to a class instance method
  • should route a message that doesn't match to the default block
    I, [2011-06-25T19:11:12.151045 #15704] INFO -- : Mailman v0.4.0 started
    D, [2011-06-25T19:11:12.151199 #15704] DEBUG -- : Processing message from STDIN.
    I, [2011-06-25T19:11:12.187413 #15704] INFO -- : Got new message from '[email protected]' with subject 'NOTE: 한국말로 하는 것'.
  • should accept a message from STDIN
    I, [2011-06-25T19:11:12.188508 #15704] INFO -- : Mailman v0.4.0 started
    I, [2011-06-25T19:11:12.188604 #15704] INFO -- : POP3 receiver enabled ([email protected]).
    I, [2011-06-25T19:11:12.188645 #15704] INFO -- : Polling disabled. Checking for messages once.
    I, [2011-06-25T19:11:12.193019 #15704] INFO -- : Got new message from '[email protected]' with subject 'Hello!'.
    I, [2011-06-25T19:11:12.197488 #15704] INFO -- : Got new message from '[email protected]' with subject 'Hello!'.
  • should poll a POP3 server, and process messsages
    I, [2011-06-25T19:11:12.229383 #15704] INFO -- : Mailman v0.4.0 started
    I, [2011-06-25T19:11:12.229719 #15704] INFO -- : POP3 receiver enabled ([email protected]).
    I, [2011-06-25T19:11:12.229770 #15704] INFO -- : Polling disabled. Checking for messages once.
  • should handle connection errors and log them to logger.error
    I, [2011-06-25T19:11:12.232898 #15704] INFO -- : Mailman v0.4.0 started
    Warning: Unable to load CarbonCore. FSEvents will be unavailable.
    I, [2011-06-25T19:11:12.304662 #15704] INFO -- : Maildir receiver enabled (/Users/arikfr/dev/Ruby/mailman_test/spec/test-maildir).
    D, [2011-06-25T19:11:12.305094 #15704] DEBUG -- : Processing new message queue...
    I, [2011-06-25T19:11:12.314171 #15704] INFO -- : Got new message from '[email protected]' with subject 'Saying Hello'.
    D, [2011-06-25T19:11:12.314655 #15704] DEBUG -- : Monitoring the Maildir for new messages...
    I, [2011-06-25T19:11:13.824843 #15704] INFO -- : Got new message from '[email protected]' with subject 'Saying Hello'.
  • should watch a maildir folder for messages
  • should match a multipart endocoded body

Mailman::Application (when config.ignore_stdin)
I, [2011-06-25T19:11:13.845207 #15704] INFO -- : Mailman v0.4.0 started

  • should not accept a message from STDIN

Mailman::Application instance variables

  • should initialize and store the router
  • should initialize and store the message processor

Mailman::Configuration

  • should have a default logger
  • should store a custom logger
  • should store the POP3 config hash
  • should have a default poll interval
  • should store the poll interval
  • should store the maildir location
  • should have a default rails root
  • should store a custom rails root
  • should default to not ignoring stdin
  • should store ignore_stdin setting

Mailman::MessageProcessor

  • should process an message and pass it to the router (FAILED - 1)

Mailman::Receiver::POP3 connection

  • should connect to a POP3 server (FAILED - 2)
  • should disconnect from a POP3 server (FAILED - 3)

Mailman::Receiver::POP3 message reception

  • should get messages and process them (FAILED - 4)
  • should delete the messages after processing (FAILED - 5)

Mailman::Route::Condition

  • should have base methods to override
  • should store the matcher
  • should define condition methods on Route

Mailman::Route::ToCondition

  • should match an address
  • should not match a non-matching address
  • should not match a nil address
  • should define a method on Route that is chainable and stores the condition

Mailman::Route::FromCondition

  • should match an address
  • should not match a non-matching address
  • should define a method on Route that is chainable and stores the condition

Mailman::Route::SubjectCondition

  • should match the subject
  • should not match a non-matching subject
  • should define a method on Route that is chainable and stores the condition

Mailman::Route::BodyCondition

  • should match the body
  • should not match a non-matching body
  • should define a method on Route that is chainable and stores the condition

Mailman::Route::CcCondition

  • should match an address
  • should not match a non-matching address
  • should not match a nil address
  • should define a method on Route that is chainable and stores the condition

Mailman::Route::Matcher

  • should have base methods to override
  • should store the pattern
  • should call #compile! when initialized

Mailman::Route::Matcher singleton

  • should have an array of registered matchers
  • should be able to find and create a matcher instance

Mailman::Route::RegexpMatcher

  • should be registered with Matcher

Mailman::Route::RegexpMatcher basic

  • should store a pattern
  • should match a string
  • should not match a non-matching string

Mailman::Route::RegexpMatcher captures

  • should return a captures hash and array with matches
  • should return empty capture arrays if there were no captures

Mailman::Route::StringMatcher

  • should be registered with Matcher

Mailman::Route::StringMatcher compiler

  • should compile to a regular expression
  • should turn tokens into keys

Mailman::Route::StringMatcher matcher

  • should return a hash of named params and an array of captures
  • should return empty results if there are no captures
  • should match a complex string
  • should capture a partial string
  • should not match a non-matching string
  • should match named params split by a period
  • should match a pattern with special characters in it

Mailman::Route

  • should match a condition
  • should match multiple conditions
  • should not match a non-matching condition
  • should not match if one condition is non-matching

Mailman::Router

  • should add a route

Mailman::Router routing

  • should set the params helper to a indifferent hash

Mailman::Router routing blocks

  • should work without args
  • should work with args

Mailman::Router routing class instance methods

  • should route to the default method
  • should route to the specified method

Mailman::Router routing array

  • should loop through routes and find the first route that matches
  • should run the first route that matches with two matching routes

Mailman::Router routing bounces

  • should run the bounce block if it exists
  • should not run the bounce block if the message did not bounce

Mailman::Router routing default

  • should run the default block if it exists and no routes match
  • should not run the default block if a route matched

Mocha::ExpectationError in 'Mailman::MessageProcessor should process an message and pass it to the router'
unexpected invocation: #<Mock:Message Router>.should_receive(:route)

spec/mailman/message_processor_spec.rb:15:in block (2 levels) in <top (required)>' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:40:ininstance_eval'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:40:in block in execute' /Users/arikfr/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:intimeout'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:37:in execute' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:219:inblock in run_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:inrun_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:103:in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:23:inblock in run'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/options.rb:153:in run_examples' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/bin/spec:5:in `

'

Mocha::ExpectationError in 'Mailman::Receiver::POP3 connection should connect to a POP3 server'
not all expectations were satisfied
unsatisfied expectations:

  • expected exactly once, not yet invoked: #<Mock:Message Processor>.process(any_parameters)

spec/mailman/receiver/pop3_spec.rb:6:in block (2 levels) in <top (required)>' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:ininstance_eval'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:in block in eval_each_fail_fast' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:ineach'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:in eval_each_fail_fast' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_hierarchy.rb:17:inrun_before_each'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:107:in run_before_each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:128:inbefore_each_example'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:39:in block in execute' /Users/arikfr/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:intimeout'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:37:in execute' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:219:inblock in run_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:inrun_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:103:in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:23:inblock in run'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/options.rb:153:in run_examples' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/bin/spec:5:in `

'

Mocha::ExpectationError in 'Mailman::Receiver::POP3 connection should disconnect from a POP3 server'
not all expectations were satisfied
unsatisfied expectations:

  • expected exactly once, not yet invoked: #<Mock:Message Processor>.process(any_parameters)

spec/mailman/receiver/pop3_spec.rb:6:in block (2 levels) in <top (required)>' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:ininstance_eval'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:in block in eval_each_fail_fast' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:ineach'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:74:in eval_each_fail_fast' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_hierarchy.rb:17:inrun_before_each'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:107:in run_before_each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:128:inbefore_each_example'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:39:in block in execute' /Users/arikfr/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:intimeout'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:37:in execute' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:219:inblock in run_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:inrun_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:103:in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:23:inblock in run'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/options.rb:153:in run_examples' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/bin/spec:5:in `

'

Mocha::ExpectationError in 'Mailman::Receiver::POP3 message reception should get messages and process them'
unexpected invocation: #<Mock:Message Processor>.should_receive(:process)
unsatisfied expectations:

  • expected exactly once, not yet invoked: #<Mock:Message Processor>.process(any_parameters)

spec/mailman/receiver/pop3_spec.rb:33:in block (3 levels) in <top (required)>' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:40:ininstance_eval'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:40:in block in execute' /Users/arikfr/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:intimeout'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:37:in execute' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:219:inblock in run_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:inrun_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:103:in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:23:inblock in run'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:in each' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/options.rb:153:in run_examples' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/bin/spec:5:in `

'

Mocha::ExpectationError in 'Mailman::Receiver::POP3 message reception should delete the messages after processing'
unexpected invocation: #<Mock:Message Processor>.process('To: [email protected]\r\nFrom: [email protected]\r\nSubject: Hello!\r\n\r\nemail message\r\ntest1')
unsatisfied expectations:

  • expected exactly once, invoked twice: #<Mock:Message Processor>.process(any_parameters)

/Users/arikfr/dev/Ruby/mailman_test/lib/mailman/receiver/pop3.rb:41:in block in get_messages' /Users/arikfr/dev/Ruby/mailman_test/spec/pop3_mock.rb:38:inblock in each_mail'
/Users/arikfr/dev/Ruby/mailman_test/spec/pop3_mock.rb:37:in each' /Users/arikfr/dev/Ruby/mailman_test/spec/pop3_mock.rb:37:ineach_mail'
/Users/arikfr/dev/Ruby/mailman_test/lib/mailman/receiver/pop3.rb:40:in get_messages' spec/mailman/receiver/pop3_spec.rb:38:inblock (3 levels) in <top (required)>'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:40:in instance_eval' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:40:inblock in execute'
/Users/arikfr/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:44:in timeout' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_methods.rb:37:inexecute'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:219:in block in run_examples' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:ineach'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:217:in run_examples' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/example/example_group_methods.rb:103:inrun'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:23:in block in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:ineach'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:22:in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/options.rb:153:inrun_examples'
/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:in run' /Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/bin/spec:5:in

'

Finished in 1.872293 seconds

84 examples, 5 failures
rake aborted!
Command /Users/arikfr/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -I"lib:lib:spec" "/Users/arikfr/.rvm/gems/ruby-1.9.2-p180@mailman/gems/rspec-1.3.2/bin/spec" "spec/functional/application_spec.rb" "spec/mailman/application_spec.rb" "spec/mailman/configuration_spec.rb" "spec/mailman/message_processor_spec.rb" "spec/mailman/receiver/pop3_spec.rb" "spec/mailman/route/condition_spec.rb" "spec/mailman/route/conditions_spec.rb" "spec/mailman/route/matcher_spec.rb" "spec/mailman/route/regexp_matcher_spec.rb" "spec/mailman/route/string_matcher_spec.rb" "spec/mailman/route_spec.rb" "spec/mailman/router_spec.rb" failed

Tasks: TOP => spec
(See full trace by running task with --trace)

Chinese characters terminating the email body

HI,

First of all thanks for the awesome gem.

I am using it but it truncates the body when it comes across chinese characters in the body thought they are rendered fine in the subject. Any solutions??

Adding date and status in conditions

To get the emails in specific date , like date(Date.today), and status , like status(:unread) , for the current solution I just can't specify the unreaded messages for today as for example

mailman with JRuby and Maildir

I am building a custom mailman application with JRuby v1.5.1 on RHEL 5 . I've setup my environment correctly with all required gems, configured Maildir, etc. and started my application from your simple_route.rb example. Every things works great with Ruby (with both Maildir and STDIN), but with JRuby, Maildir configuration does not work, there is no output whatsoever - but STDIN does work (cat ../spec/fixtures/example01.eml | ./simple_route_jruby.rb).

Are there any know issues running mailman with JRuby? I have the latest FSSM (0.1.4) gem installed with JRuby and notes on the repo say it should work with JRuby. Much thanks

Issue loading rails app (2.1.2)

Hello, I have written a script (working) and I have put it at the root of my rails application, positionned the rails_root config to '.' but when I try ti run the script I got the following error message:
Rails root found in ., requiring environment...
Missing the Rails 2.1.2 gem. Please gem install -v=2.1.2 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

This app is running rails 2.1.2 and is loading correctly with RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION

I don't know if it is a mailman issue, but as you susggested I submit that as an issue
Nicolas

name collision

'mailman' is already the name of a large, old, popular open source email project

Adding Rack integration

I'm working on a simple Rack endpoint which processes messages POSTed to it using Mailman. The purpose is to re-use the Mailman router when receiving mail from a third-party site such as CloudMailin.

Would you be interested in merging this at some point? The code currently resides at http://github.com/dasch/mailman/tree/rack-receiver

I'll make a pull request if you want to, but it may be a bit immature, I've only been working on it for a few hours.

Update fssm to guard/listen

With mailman (0.4.0) and fssm (0.2.9) I get a message:

Dear developers making use of FSSM in your projects,
FSSM is essentially dead at this point. Further development will
be taking place in the new shared guard/listen project. Please
let us know if you need help transitioning! ^_^b

  • Travis Tilley

Now I lock fssm to < 0.2.9 to fix it.

gem install fail

not

gem install mailman

instead of

gem 'daemons'
gem 'mailman', require: false
gem 'maildir'
gem 'mail'

Occasional "EOFError: end of file reached" exception

For days at a time, mailman works great. Then every so often I get the exception "EOFError: end of file reached" which crashes the mailman server.

Here is the stack trace:

/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/openssl/buffering.rb:174:in `sysread_nonblock'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/openssl/buffering.rb:174:in `read_nonblock'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:996:in `recv_response'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:992:in `get_response'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:905:in `block in auth'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:1012:in `critical'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:904:in `auth'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:566:in `do_start'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:538:in `start'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/receiver/pop3.rb:29:in `connect'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:117:in `block in polling_loop'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:115:in `loop'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:115:in `polling_loop'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:75:in `run'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:7:in `run'

Can't *not* monitor a MailDir

Before monitoring a maildir, it should check the poll_interval is not '0' (in case you just want to run a test of picking stuff up from a maildir, without it hanging "forever")

Mailman::Rails

Hi @titanous, I'm thinking of writing a gem "mailman-rails" which will assist mailman integration with Rails. I'm going to add rake tasks which manage running mailman as a daemon, and was also thinking of modifying Mailman::Application so that you could specify your Routes and Conditions within the models before the Mailman::Application started running. For this, I'd need to store an instance of Mailman::Application, so I have two questions:
(1) Is there any use case which requires multiple instances of Mailman::Application?
(2) Would you want this behaviour in Mailman, or shall I monkey-patch it in Mailman::Rails?

How to pull same emails repeatedly from Gmail using POP3 receiver

I am using POP3 receiver to pull emails from a Gmail account. The GMail account is setup to retain a copy of the email. During testing, I'd like to pull the same set of emails over and over, but Mailman only pulls the messages once. How does it keep track of which emails have been pulled? Can it be configured to not remember which emails have been pulled so that each time it runs, it pulls the same emails again?

polling not working (pop3)

Hello,
I have 2 issues with the polling
1- when I launch the application and that there is a message in the inbox, it works fine but the next polling generates the following error
got a message for id: 7crussol
Polling POP3 server for messages...
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:978:in check_response': -ERR Message is deleted. (Net::POPError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:965:ingetok'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:931:in retr' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:990:incritical'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:930:in retr' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:786:inpop'
from /Library/Ruby/Gems/1.8/gems/mailman-0.2.0/lib/mailman/receiver/pop3.rb:39:in get_messages' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:645:ineach'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/pop.rb:645:in each_mail' from /Library/Ruby/Gems/1.8/gems/mailman-0.2.0/lib/mailman/receiver/pop3.rb:38:inget_messages'
from /Library/Ruby/Gems/1.8/gems/mailman-0.2.0/lib/mailman/application.rb:53:in run' from /Library/Ruby/Gems/1.8/gems/mailman-0.2.0/lib/mailman/application.rb:51:inloop'
from /Library/Ruby/Gems/1.8/gems/mailman-0.2.0/lib/mailman/application.rb:51:in run' from /Library/Ruby/Gems/1.8/gems/mailman-0.2.0/lib/mailman/application.rb:7:inrun'
from mailman_app.rb:14

2- if I launch my script when there is no mail in the queue and then if I send a message while mailman_app.rb is running, the next polls doesn't fetch anything.

Here is my code

require 'rubygems'
require 'mailman'
require 'mailman_cond_extension'

Mailman.config.pop3 = {
:username => '*@xxx.com',
:password => 'xxx',
:server => 'pop.xxx.com',
:port => 110 # defaults to 110
}
Mailman::Application.run do
to("%id%@xxx.com") do
puts("got a message for id: #{params[:id]}")
end

default do
puts("ignored")
end

end

Can't get imap to work

I know the docs say IMAP isn't directly supported, but I see a merge of IMAP, and I see the code in the repo - it looks like it should work, and maybe just isn't documented? However, I can connect, but no messages are pulled down.

Mailman.config.imap = {
  server: 'imap.gmail.com',
  username: '[email protected]',
  password: 'password',
  port: 993,
  ssl: true
}

When I start Mailman, it says IMAP receiver enabled, and says it's polling, but then nothing happens. I understand this is possibly just not working code to begin with (not documented so not a feature), but from everything I see in the old closed issues, this should be working. Am I doing something wrong?

Thank you!

Occasional "Timeout::Error: execution expired" exception

For days at a time, mailman works great. Then every so often I get the exception "Timeout::Error: execution expired" which crashes the mailman server.

A configurable timeout which we can set to nil (or something like 5 minutes) would be very handy.

Here is the stack trace:

/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:545:in `initialize'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:545:in `open'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:545:in `block in do_start'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:545:in `do_start'
/home/user/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/net/pop.rb:538:in `start'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/receiver/pop3.rb:29:in `connect'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:117:in `block in polling_loop'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:115:in `loop'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:115:in `polling_loop'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:75:in `run'
[GEM_ROOT]/gems/mailman-0.6.0/lib/mailman/application.rb:7:in `run'

Mailman.config.rails_root = nil is ignored

Hi,

I have a mailman script inside a rails application folder, but I don't want to use it inside the Rails environment. According to the documentation, if a set my Mailman.config.rails_root configuration to nil the rails env will not be loaded.

Turns out that the mailman/config.rb sets the default value if the one set is nil, in the line 33 :

def rails_root
     @rails_root ||= '.'
end

I could send a patch, but since you guys have an spec testing this behavior I assume that this can be an error in the documentation.

Using Mailman.config.rails_root = '' seems to work fine for this purpose.

Any thoughts? Should we fix the code or the documentation?

New Release?

Hey Jonathan! Are you going to release a new version of the gem with the recent changes and bug fixes? Since the last release (0.7.0) there have been some commits I'm very interested in. Especially this one:

deb07b1

Parsing bcc is not possible, Even tried modifying module :(

I tried modifying the module but its not helping me out to parse bcc from the email object. Can you help me?

module Mailman
  class Route

    # Matches against the BCC addresses of a message.
    class BccCondition < Condition
      def match(message)
        if !message.bcc.nil?
          message.bcc.each do |address|
            if result = @matcher.match(address)
              return result
            end
          end
        end
        nil
      end
    end
  end
end

loading mailman fails when including rails application

Error Output

I, [2013-10-09T10:32:48.726882 #7407]  INFO -- : Mailman v0.7.0 started
I, [2013-10-09T10:32:48.727063 #7407]  INFO -- : Rails root found in /RAILS_ROOT, requiring environment...
I, [2013-10-09T10:32:55.412775 #7407]  INFO -- : POP3 receiver enabled ([email protected]).
/usr/local/rvm/gems/ruby-1.9.3-p392@gemset/gems/mailman-0.7.0/lib/mailman/application.rb:83:in `run': cannot load such file -- mailman/receiver (LoadError)
    from /usr/local/rvm/gems/ruby-1.9.3-p392@gemset/gems/mailman-0.7.0/lib/mailman/application.rb:11:in `run'
    from mailman_app.rb:23:in `<main>'

Script

require 'mailman'

Mailman.config.rails_root = File.expand_path('../../RAILS_ROOT',  __FILE__)
Mailman.config.poll_interval = 10
Mailman.config.maildir = 'Maildir'

Any Ideas to solving that issue?

Thanks, Sebastian

Script stops working

Script stops working after a while. So it should be? I work with three mailboxes, and everyone has a script. Perhaps for this reason, they are turned off, or it must be so? Thanks for the reply.

Watching maildirs will not daemonize

Thanx for putting the effort in this wonderful piece of software.

In an effort to daemonize mailman while watching a maildir, I had to change mailman-0.6.0/lib/mailman/application.rb:100
from: @Listener.start
to: @Listener.start!

To make it a blocking call. Otherwise listen will run non-blocking and application.run will exit after the first cycle....

POP3: Encoding troubles

Ruby: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]

I see something like
Got new message from '[email protected]' with subject 'Fwd: ID ÷ÏÏ35 ïë'.
instead
Got new message from '[email protected]' with subject 'Fwd: ID Яоо35 ОК' (cyrillic chars)

It would be great if I can set encoding of emails

Limit number of popped emails per polling cycle?

Excellent gem!

I am using mailman to extract emails from a POP3 server.

There are a very large number of emails in the POP account to process (i.e. > 250 000).

Is there a way to limit the number of emails that are extracted in each polling cycle?

multiple maildirs?

hi -

maybe i am misunderstanding how mailman works (definitely possible) but it looks like the Maildir you can set is global. it would be cool if i could specify a set of maildir(s) for mailman to check, so like user1/Maildir, user2/Maildir, etc and then have my routes get applied to mails from all those places.

it would be useful if when my route gets hit, it passes down the path to the mail so i know where it came from.

i keep a "failed" directory in each maildir for mails that fail to be processed for whatever reason, so user1/Maildir/failed, user2/Maildir/failed, ... for example.

thoughts?

uninitialized constant Fcntl::F_GETFL (NameError) for Windows

When trying to run the sample with Mailman User Gaudet, I get an error like this:

C:\Sites\MailMan\script>ruby mailman_server.rb
I, [2012-11-16T15:59:41.436378 #1920] INFO -- : Mailman v0.5.3 started
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mailman-0.5.3/lib/mailman/application.rb:52:in run': uninitialized constant Fcntl::F_GETFL (NameError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mailman-0.5.3/lib/mailman/application.rb:7:inrun'
from mailman_server.rb:14:in `

'

What am I doing wrong?

Requiring the POP3 Receiver class

There seems to be an issue with autoload and requiring the pop3 receiver. I created a mailman_app.rb in my Rails root and it failed with:

I, [2010-10-09T15:42:05.592186 #36925]  INFO -- : Mailman v0.4.0 started
I, [2010-10-09T15:42:05.592288 #36925]  INFO -- : Rails root found in ., requiring environment...
POP3 receiver enabled ([email protected]).
Polling enabled. Checking every 60 seconds.
/Library/Ruby/Gems/1.8/gems/mailman-0.4.0/lib/mailman/application.rb:54:in `run': no such file to load -- mailman/receiver (LoadError)
from /Library/Ruby/Gems/1.8/gems/mailman-0.4.0/lib/mailman/application.rb:7:in `run'
from mailman_app.rb:14

I poked around the source and suspected the problem was related how the pop3 class was required. I removed everything with autoload and required it directly and it worked. I'm not sure what your intentions are, but I also got it to work by including directly in my mailman_app.rb

require 'mailman'
require 'mailman/receiver/pop3'

/usr/local/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/application.rb:106:in `run': undefined method `change' for #<Listen::Listener:0x007f2dba810af8> (NoMethodError)

Hello,

Great piece of software!

Running rails 3.2.16 and ruby 2.1.1p76 results in:

/usr/local/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/application.rb:106:in run': undefined methodchange' for #Listen::Listener:0x007f2dba810af8 (NoMethodError)
from /usr/local/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/application.rb:11:in run' from /var/www/njoin/daemons/mailman.rb:8:in<top (required)>'
from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:203:in load' from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:203:instart_load'
from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:298:in start' from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/controller.rb:73:inrun'
from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons.rb:147:in block in run' from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:incall'
from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in catch_exceptions' from /usr/local/lib/ruby/gems/2.1.0/gems/daemons-1.1.9/lib/daemons.rb:146:inrun'
from ./script/daemon:12:in `

'

how to handle exceptions gracefully

Trying to use either POP3 or Maildir. If I have an exception occur while processing message, the message is still processed (i.e. deleted in POP3 or moved to cur in Maildir). Example:

Mailman.config.maildir = '~/Maildir'

Mailman::Application.run do
default do
begin
puts message.to_s
raise 'problem'
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
Mailman.logger.error [e, *e.backtrace].join("\n")
end
end
end

undefined method `each' for "\"lvivol ict (Групи Google)\" <[email protected]>":String

In script/mailman_server:

#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"

Mailman.config.logger = Logger.new("log/mailman.log")

Mailman.config.pop3 = {
  server: 'pop.gmail.com', port: 995, ssl: true,
  username: '',
  password: ''
}

Mailman::Application.run do
  to '[email protected]' do
    begin
      puts message.inspect
    rescue Exception => e
      Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
      Mailman.logger.error [e, *e.backtrace].join("\n")
    end
  end
end

Just executed like a script chmod +x script/mailman_server and run script/mailman_server.

In few seconds i received next error:

/home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/route/conditions.rb:21:in `match': undefined method `each' for "\"lvivol ict (Групи Google)\" <[email protected]>":String (NoMethodError)
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/route.rb:29:in `block in match!'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/route.rb:28:in `each'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/route.rb:28:in `match!'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/router.rb:48:in `block in route'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/router.rb:47:in `each'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/router.rb:47:in `route'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/message_processor.rb:23:in `block in process'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/middleware.rb:33:in `call'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/middleware.rb:33:in `block in run'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/middleware.rb:38:in `call'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/middleware.rb:38:in `run'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/message_processor.rb:22:in `process'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/receiver/pop3.rb:43:in `block in get_messages'
    from /home/voleksyn/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/pop.rb:665:in `each'
    from /home/voleksyn/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/pop.rb:665:in `each_mail'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/receiver/pop3.rb:42:in `get_messages'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/application.rb:133:in `block in polling_loop'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/application.rb:130:in `loop'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/application.rb:130:in `polling_loop'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/application.rb:83:in `run'
    from /home/voleksyn/.rvm/gems/ruby-2.0.0-p247@mc/gems/mailman-0.7.0/lib/mailman/application.rb:11:in `run'
    from script/mailman_server:14:in `<main>'

Can you help? How I can fix it?

type_cast: can't cast Mail::AddressContainer to string

I was watching the RailsCast that covers handling incoming emails with Mailman.

I have the file script/mailman_server

Mailman::Application.run do
  default do
    Email.create(to: message.to,
                          from: message.from,
                          subject: message.subject,
                          body: message.body.decoded)
  end
end

I have a sample email at lib/mailman_test.eml

Date: Fri, 18 Mar 2014 14:36:00 -0600
From: [email protected]
Subject: Mailman test
To: [email protected]

This is a test email.

When I run cat lib/mailman_test.eml | script/mailman_server, I get the following error.

/home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/quoting.rb:76:in `type_cast': can't cast Mail::AddressContainer to string (TypeError)
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql/quoting.rb:104:in `type_cast'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:783:in `block in exec_cache'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:782:in `map'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:782:in `exec_cache'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:139:in `block in exec_query'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:430:in `log'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:184:in `exec_insert'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:96:in `insert'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/relation.rb:76:in `insert'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/persistence.rb:509:in `create_record'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/attribute_methods/dirty.rb:78:in `create_record'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/callbacks.rb:306:in `block in create_record'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:373:in `_run__3606689065456724534__create__callbacks'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:80:in `run_callbacks'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/callbacks.rb:306:in `create_record'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/timestamp.rb:57:in `create_record'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/persistence.rb:477:in `create_or_update'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/callbacks.rb:302:in `block in create_or_update'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:373:in `_run__3606689065456724534__save__callbacks'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:80:in `run_callbacks'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/callbacks.rb:302:in `create_or_update'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/persistence.rb:106:in `save'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/validations.rb:51:in `save'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/attribute_methods/dirty.rb:32:in `save'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:270:in `block (2 levels) in save'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:209:in `transaction'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:270:in `block in save'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:281:in `rollback_active_record_state!'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/transactions.rb:269:in `save'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.3/lib/active_record/persistence.rb:37:in `create'
    from /home/dennis/github/incoming-emails-sendgrid/app/models/email.rb:4:in `receive'
    from script/mailman_server:16:in `block (2 levels) in <main>'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/router.rb:66:in `instance_exec'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/router.rb:66:in `route'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/message_processor.rb:23:in `block in process'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/middleware.rb:33:in `call'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/middleware.rb:33:in `block in run'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/middleware.rb:38:in `call'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/middleware.rb:38:in `run'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/message_processor.rb:22:in `process'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/application.rb:71:in `run'
    from /home/dennis/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailman-0.7.0/lib/mailman/application.rb:11:in `run'
    from script/mailman_server:7:in `<main>'

I'm using Rails 4.0.3, Ruby 2.1.1, and PostgreSQL.

My db/schema.rb

ActiveRecord::Schema.define(version: 20140318194844) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "emails", force: true do |t|
    t.string   "subject"
    t.text     "body"
    t.string   "header"
    t.string   "to"
    t.string   "from"
    t.string   "bcc"
    t.string   "cc"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "inquiries", force: true do |t|
    t.string   "name"
    t.string   "phone"
    t.string   "email"
    t.date     "movein_date"
    t.string   "length_of_stay"
    t.text     "comments"
    t.string   "ad_url"
    t.string   "property"
    t.string   "ad_title"
    t.string   "ad_network"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

end

Implement the LMTP protocol

The Local Mail Transfer Protocol (LMTP) is a variant of SMTP designed for local, inter-process delivery of mail. I believe this could be much more efficient than dropping the mails in a maildir, or using POP3.

Of course, implementing LMTP would be a big undertaking, but I just wanted to mention it here.

The RFC can be found at http://www.ietf.org/rfc/rfc2033.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.