How to make a script like e.g. 'script/mailman_server' work for multiple users in a Rails app -
i have rails app uses mailman gem (link) collect inbound pop3 mails , stuff them. works fine, wish have multiple users sign , receive mails pop3 configuration. mailman run in 'script/mailman_server', , unfamiliar how make script (thats running own process) work multiple users. enlighten me on subject or link resource touches subject?
this code 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 default 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
Comments
Post a Comment