1

I have a Rails app that uses the mailman gem (link) to collect inbound pop3 mails and do stuff with them. It all works just fine, but now I wish to have multiple users sign up and receive mails from their pop3 configuration. Mailman is run in 'script/mailman_server', and I am unfamiliar with how to make a script (thats running its own process) work for multiple users. Could anyone enlighten me on the subject or link to a resource that touches this subject?

This is my code as of now

# script/mailman_server

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

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

Mailman::Application.run do
  default do
    Email.receive_mail(message)
  end
end


# app/models/email.rb

class Email
  include Mongoid::Document
  include Mongoid::Timestamps

  field :from, type: String
  field :subject, type: String
  field :body, type: String

  belongs_to :customer, :inverse_of => :emails

  def self.receive_mail(message)
    email = Email.create!(subject: message.subject, body: message.body.decoded, from: message.from.first)
  end
end
Cjoerg
  • 1,271
  • 3
  • 21
  • 63
  • I don't think it is possible in this gem unless you do forwarding from the other mail accounts to the configured one, as seen in this [http://stackoverflow.com/questions/12178349/receive-emails-from-multiple-accounts-using-mailman-gem-in-rails](example). – Hartmut Apr 21 '13 at 14:17
  • Thanks for your answer. This solution unfortunately won't be suitable for my case. Mails from each mail account must not be mixed together. Do you have a suggestion to an alternative solution? – Cjoerg Apr 21 '13 at 17:23
  • I am searching myself. The only idea I had which would probably could work is to set up an standard imap server like CyrusImap mail and use http://mailr.org/ as the interface. But then you don't have an integration. – Hartmut Apr 23 '13 at 18:43

0 Answers0