How to get an email response to a rails application from an email server

I need to implement a messaging feature. When I send a message to any user from my rails application, it is also sent to the users email address. But what I need to implement is if the user who received the email sent a response from gmail, yahoo..etc, then the response should also go into the rails app. can anyone guide me somehow .. so i can find it on google.

Example:

If I send an email to the user from this letter " mc-6bckm434ls@reply.xyz.com ", and the user replies to gspq5diedss@reply.xyz.com , which I set Reply-To in the header. Then I need a custom response in my rails application so that I can add this user response to the message flow. For this function that I want to implement, the user does not need to log into my application to make messages, the user can also send messages via the current conversation via e-mail.

+6
source share
4 answers

Since you noted the SendGrid question, I assume you are using it. You can use SendGrid Inbound Parse Webhook to handle parsing incoming messages.

We also have a recent tutorial that goes through using web hosting in the rails app: http://sendgrid.com/blog/two-hacking-santas-present-rails-the-inbound-parse-webhook/

+7
source

It is possible!

You can use mailman , for example.

All you have to do is set the Reply-To header in your email to make it unique, so when you retrieve messages that you know that matches it.

For example, let's say you have an email address foo@bar.com

You can send emails with the response header " foo+content_id@bar.com " so that you know what the user is responding to.

Then, mailman can retrieve messages from the mailbox and parse the content identifier in them.

Some services also do this by processing all of the email and sending you notifications of incoming emails, such as postmark

+1
source

See https://github.com/titanous/mailman/blob/master/USER_GUIDE.md

There is a link to the use of the gem, but its paid: - / http://railscasts.com/episodes/313-receiving-email-with-mailman ,

however there is a github repository from railscast that can show you an example of an application that uses mailman (with before and after so you can track the changes) - https://github.com/railscasts/313-receiving-email-with-mailman

0
source

Ruby on Rails introduces Action Mailbox in version 6.0

Using ActionMailbox, you can easily configure rules for routing incoming emails (examples from the documentation):

 # app/mailboxes/application_mailbox.rb class ApplicationMailbox < ActionMailbox::Base routing /^ save@ /i => :forwards routing /@replies\./i => :replies end 

And how to handle specific messages in the mailbox:

 # app/mailboxes/forwards_mailbox.rb class ForwardsMailbox < ApplicationMailbox # Callbacks specify prerequisites to processing before_processing :require_forward def process if forwarder.buckets.one? record_forward else stage_forward_and_request_more_details end end private def require_forward unless message.forward? # Use Action Mailers to bounce incoming emails back to sender – this halts processing bounce_with Forwards::BounceMailer.missing_forward( inbound_email, forwarder: forwarder ) end end def forwarder @forwarder ||= Person.where(email_address: mail.from) end def record_forward forwarder.buckets.first.record \ Forward.new forwarder: forwarder, subject: message.subject, content: mail.content end def stage_forward_and_request_more_details Forwards::RoutingMailer.choose_project(mail).deliver_now end end 

Find the documentation for configuring Action Mailbox and some examples in the Rails Guides .

0
source

All Articles