Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active December 12, 2015 00:18
Show Gist options
  • Select an option

  • Save toolmantim/4682623 to your computer and use it in GitHub Desktop.

Select an option

Save toolmantim/4682623 to your computer and use it in GitHub Desktop.
Here's a sketch of my ideal gem for designing, auditing and cross-browser testing HTML emails in Rails applications. This could be built upon the work of the existing 37signals/mail_view.
# Gemfile
group :development do
gem 'mail_preview'
end
# config/initializers/mail_preview.rb
MailPreview.configure do |c|
c.litmus subdomain: "company",
username: "root",
password: "123",
name_prefix: "MyApp"
end
# app/mailers/previews/registration.rb
require 'factory_girl'
mail_preview "RegistrationMailer.welcome", "Sent after a user creates an account" do
user = FactoryGirl.create(:user)
RegistrationMailer.welcome(user)
end
mail_preview "RegistrationMailer.goodbye", "Sent after a user deletes their account" do
# or using standard fixtures
user = users(:bob)
RegistrationMailer.goodbye(user)
end
# http://localhost:3000/mail-previews/email-1/html
# |----------------------------------------|
# | Group | Description of email |
# | *Email 1* |----------------------------|
# | Email 2 | *HTML* | Text | Litmus |
# | |----------------------------|
# | | |
# | | |
# | | |
# | | |
# | | |
# | | |
# | | |
# |----------------------------------------|
# http://localhost:3000/mail-previews/email-1/litmus
# |----------------------------------------|
# | Group | Description of email |
# | *Email 1* |----------------------------|
# | Email 2 | HTML | Text | *Litmus* |
# | |----------------------------|
# | | |
# | | Never tested. |
# | | |
# | | [ Test ] |
# | | |
# | | |
# | | |
# | | |
# | | |
# |----------------------------------------|
# http://localhost:3000/mail-previews/email-1/litmus
# |----------------------------------------|
# | Group | Description of email |
# | *Email 1* |----------------------------|
# | Email 2 | HTML | Text | *Litmus* |
# | |----------------------------|
# | | |
# | | Last test 14 days ago: |
# | | |
# | | |----| |----| |----| |
# | | | | | | | | |
# | | ------ |----| |----| |
# | | iPhone Android Blackb |
# | | |
# | | [ Retest ] |
# | | |
# | | Previous tests: |
# | | * 18 days ago |
# | | * 24 days ago |
# | | |
# |----------------------------------------|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment