I'm trying to set up my RoR 3 application to receive emails and then process those emails and update them into the database table called product_comments.
In my application, I have products_controller. Admin can approve or disapprove the products. when the admin disapproves the product, admin adds a comment and that comment will be mailed to the artist, if artist replied to that mail, the product_comments table should be updated to store the replied comment and replied date.
Here is (part of) what I have in my products controller:
if @productcomment.save
ArtistProduct.where(:id=>params[:id]).update_all(:astatus=>'disapproved', :status=>'disapproved')
UserMailer.comment_email( @productcomment).deliver
end
When users add a comment, the admin receives an email. When admins add a comment, users receive an email. (This is already functioning.)
I'm using Cloudmailin to help me receive incoming mail. I've set up the Cloudmailin address to point to http://myapp.com/incoming.
I am not getting how to integrate Cloudmailin to my application. Please help me.
UPDATE
I have just created incoming controller and my incoming controller looks like:
require 'mail'
def create
@comment = ProductComment.find_by_token(params[:to].split('@')[0])
ProductComment.update(:id=>@comment.id,{:reply => params[:plain], :rfrom=>params[:from], :replieddate=>params[:date]})
render :text => 'success', :status => 200
end
My question is how i will get the comment id? While sending an email i want specify comment id or not? if want to specify that id where i want to specify. I have created one account in Cloudmailin is that enough for process the incoming mail or i need to follow any other steps to receive the mail to my application? that is any server setting should be done or what. I am getting any thing. Please help.
Now am sending an email like:
mail(:to => @user.email, :subject => "Edit Your Product")
and i Have set the from as default and it looks like:
default from: "[email protected]"
This is the admin email address. Please help me.
You can use mailman.
The user guide has an example that does just what you are asking for.