Sha256: 0ea75faabf8b0f02730a9cb672dc744c3e99bd8f8144eee072d8a68238325753

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

if ActionMailer::VERSION::MAJOR == 3
  require 'action_dispatch/http/mime_type' # needs to be required to avoid an error: uninitialized constant AbstractController::Collector::Mime
end

class TestMailer < ActionMailer::Base
  # template root must be set for multipart emails, or ActionMailer will throw an exception.
  if respond_to?(:view_paths)
    view_paths.unshift File.dirname(__FILE__)
  else
    template_root File.dirname(__FILE__)
  end

  def plain_text_message(options)
    setup_recipients(options)
    from       'test@mailsafe.org'
    subject    "Plain text Message Test"
    body       "Here is the message body."
  end

  def html_message(options)
    setup_recipients(options)
    from       'test@mailsafe.org'
    subject    "Html Message Test"
    body       "<p>Here is the message body.</p>"
    content_type 'text/html'
  end

  def multipart_message(options)
    setup_recipients(options)
    from       'test@mailsafe.org'
    subject    "Html Message Test"

    content_type 'multipart/alternative'

    part :content_type => 'text/plain', :body => "Here is the message body."
    part :content_type => 'text/html',  :body => "<p>Here is the message body.</p>"
  end

  protected

  def setup_recipients(options)
    recipients options[:to]
    cc         options[:cc]
    bcc        options[:bcc]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mail_safe-0.3.0 spec/spec/mailers/test_mailer.rb