Reputation: 53
I have sent email through rails app using sendgrid and actionmailer, I also received the mail. But I want status of the email sent (open,deliver,bounce..) of sendgrid in my rails app so that that response of particular email i can save in my database.
I have followed: https://github.com/stephenb/sendgrid for sending email and it worked for me.
Upvotes: 5
Views: 5088
Reputation: 13188
You should setup the event webhook for your app. Once you do, you'll get POSTs to your app in the format:
{
"email":"[email protected]",
"timestamp":1322000095,
"unique_arg":"my unique arg",
"category": "some_category",
"event":"delivered"
}
Since you're using Rails, you should also check out GridHook. SendGrid doesn't officially support it, but there are a number of people in the open source community working on it. With that, you'll be able to do something like:
Gridhook.configure do |config|
# The path we want to receive events
config.event_receive_path = '/sendgrid/event'
config.event_processor = proc do |event|
# event is a Gridhook::Event object
EmailEvent.create! event.attributes
end
end
Upvotes: 1
Reputation: 19050
To get status of sent email, use sendgrid webhooks as described here
Once this is setup, sendgrid will notify your url for the following events:
Upvotes: 2