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

CSS and ActionMailer in Rails3.

Lately, I was working on a project where I found an issue that emails sent using ActionMailer were not applying css styles to the html elements of the email. On adding style tag in the email view files, I was able to view stylings on thunderbird mail and ymail but still I was unable to view css stylings for emails in gmail. On furthur investigating the issue, I found that gmail requires inline stylings to be applied to the email templates. I found some gems which could fix this problem by converting external css to inline css. I tried the