HasWebFallback

Extracts the common behaviour of wanting online versions of html emails.

If a mailer function is described as has_web_fallback two things will happen.

  1. The template will get access to an @web_fallback_url, a url (relative to /) to the web version of the email

  2. After sending, if the email has an html part, that part will be written out to the public directory.

Future Features

Customizable urls/paths

Installation

Right now, HasWebFallback requires UUIDTools to generate the names for the emails. config.gem ‘uuidtools’

Example

class ExampleMailer < ActionMailer::Base

has_web_fallback :welcome, :keep_for=>7.days has_web_fallback :goodbye, :keep_for=>10.minutes

def welcome # end

def goodbye # end end

… and in the template

<%= link_to(“View this email online”, APPLICATION_URL+@web_fallback_url) %>

Copyright © 2009 Gavin Montague, released under the MIT license