Switch email provider at runtime in a Ruby on Rails application

Recently we had a requirement where emails were to be delivered to a specific group of users by switching the provider at run time. In short, we are required to deliver the emails by dynamically selecting a provider and not just through a pre-configured provider. Rails provide these Dynamic Delivery Options to override the SMTP settings per mail. But, if you have an existing application with various mailers, applying delivery_method_options will require updating individual mailer action. In this blog, we'll go through the approaches that will work without modifying any existing mailer actions. Setup Assuming that your default

Communicating with Sendgrid V3 API

Sendgrid provides email service which we can use for sending emails from our app and we can even track every details of any email sent through our Sendgrid account like whether it is delivered, opened, dropped and details of unsubscribed email addresses etc. There are also API endpoints provided by Sendgrid to access user subscribe/unsubscribe related data and email event data with respect to emails sent through your sendgrid account for which documentation link is provided at bottom. To understand this lets go through simple example to fetch sendgrid subscription groups data from your sendgrid account - Generate API

Integrating Sendgrid with your Application to receive Email related Events.

We've one Blogging application and whenever User post a new Article we wanted to show that to whom his/her post is delivered, who has opened a post or clicked.. events like that. So that User will know how many people are reading his/her post and also how often. We were already using services of Sendgrid. Now Sendgrid provides different APIs for different purposes. Some of them I'm listing below. SMTP API, WEB API, EVENT WEBHOOK, PARSE API. Now, We needed EVENT WEBHOOK API for what we wanted to achieve. Here is a link to EVENT WEBHOOK API. The