Sha256: b88546d3484ca87665358782974cbbe0b89d4d3a07728bde1f93b82681cba7aa

Contents?: true

Size: 874 Bytes

Versions: 5

Compression:

Stored size: 874 Bytes

Contents

class UserMailer < ActionMailer::Base
  default :from => "admin@example.com",
          :sent_on => Time.now.to_s
  
  
  def signup(email, name)
    @name = name
    
    mail :to => email,
         :subject => "Account confirmation"
  end

  def newsletter(email, name)
    @name = name
    
    mail :to => email,
         :subject => "Newsletter sent"
  end

  def attachments_mail(email, name)
    @name = name
    
    add_attachment 'image.png'
    add_attachment 'document.pdf'
    
    mail :to => email,
         :subject => "Attachments test"
  end

  private

  def add_attachment(attachment_name)
    attachment_path = "#{Rails.root}/attachments/#{attachment_name}"
    File.open(attachment_path) do |file|
      filename = File.basename(file.path)
      attachments[filename] = {:content_type => File.mime_type?(file), :content => file.read}
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
email_spec-1.0.1 examples/rails3_root/app/mailers/user_mailer.rb
email_spec-1.2.1 examples/rails3_root/app/mailers/user_mailer.rb
email_spec-1.2.0 examples/rails3_root/app/mailers/user_mailer.rb
email_spec-1.1.1 examples/rails3_root/app/mailers/user_mailer.rb
path-email_spec-0.6.2 examples/rails3_root/app/mailers/user_mailer.rb