views:

625

answers:

3

Hello Ruby/Rails/Merb developers!

Im currently working on a web project that will have a feature to communicate with clients by email. So, let`s say i created account for a customer in my admin panel, then created a topic/thread to discuss questions, tasks and other work-related stuff. So, the customer will receive email notification. Also customer will be able to log-in into the system and write responses within the system. But what im trying to do is: after customer responded to notification (which contains special identification code of message), i need to import that response into the thread. It makes communication between clients really convenient.

Also, the solution needs to operate with file attachments too.

The only one way i can do this right now is to develop special mail-checking daemon, that will be fetching mail from notifications account and automatically add data to central database. Probably, it is not a best idea.

I have seen such example in 37signals` BaseCamp software.

Question: What is the best practices do to this?

+1  A: 

Another approach to be aware of is to pipe the email from an MTA (postfix, sendmail) right from the aliases file into a program that you write to process the mail and put it into your application.

/etc/aliases:
your-application-email: /path/to/your/email/receiving/script

The Mailman mailing list manager uses this approach. The downside is that it requires access the the system's mail configuration. Probably not an issue with the scope of your application though.

Jason stewart
+1  A: 

I believe that your own solution, the mail fetching script, would be the best way to go about this. Piping or otherwise directly receiving the mail from ruby runs the risk of losing messsages if there's a glitch in your application. Let a mail server do the heavy lifting and poll it once in a while.

Ruby comes with Net::IMAP support in the standard library.

Anders Johannsen
A: 

(incomplete answer...sorry) Our team uses Redmine's email monitoring feature that works REALLY well. It seems to implement everything you mentioned above except attachments.

You could probably borrow that functionality with very little tweaking :-)

redmine.org

btelles