receive email and store on the database

I have developed a messaging system on rails3.As per the requirements, the incoming mails will contains the messages and that needs to be stored on the on the DB, with respect to the email id users.

Please help on this