Receiving mail into Rails has never been easier! LMTP server which delivers to MongoDB.
Ruby
Permalink
Failed to load latest commit information.
bin
lib
spec
.gitignore
.rspec
Gemfile
LICENSE
README.md
Rakefile
received.gemspec

README.md

ReceiveD

ReceiveD is yet another way for receiving mail with Rails. Why have yet another subsystem (like IMAP), when you can deliver the mail directly to your data store?

ReceiveD is almost RFC2033 compliant LMTP server built around eventmachine and as such should be quite fast.

The receive daemon will listen on TCP or UNIX socket, and write the mail to the backend storage.

Currently only MongoDB is supported, but writing another backend (MySQL, Redis, etc.) is trivial.

Installation

sudo gem install received

Modify your Postfix configuration to deliver mail via LMTP to TCP or UNIX socket.

Example main.cf:

virtual_transport = lmtp:192.168.2.106:1111
virtual_mailbox_domains = example.com

Create a YAML configuration file which has the following parameters:

{'production'=>{'host'=>hostname, 'database'=>db, 'collection'=>col}}

The mongoid.yml will do, just add the name of collection, i.e.

production:
  <<: *defaults
  database: foo_production
  collection: inbox

The default environment is production, but you can specify other environment using RAILS_ENV environment variable. In this case, make sure you have the relevant key in your configuration file.

Running

Check -h for help, port/unix socket path and config file are required.

Bugs and missing features

  • When using UNIX socket the permissions/ownership are not changed. Use -u and -g when running as daemon or change the permissions/ownership manually.
  • ReceiveD wasn't really tested for compliance with RFC2033
  • It doesn't implement RFC2034 (ENHANCEDSTATUSCODES), because Postfix doesn't seem to care
  • It doesn't perform any validation of the provided input, e.g. LHLO, MAIL FROM, RCPT TO

Copyright (c) 2011 Roman Shterenzon, released under the MIT license