Class: Merb::Mailer

Class | Merb::Mailer
In: | lib/merb-mailer/mailer.rb
Parent: | Object

You‘ll need a simple config like this in init.rb if you want to actually send mail:

      Merb::Mailer.config = {
        :host   => 'smtp.yourserver.com',
        :port   => '25',
        :user   => 'user',
        :pass   => 'pass',
        :auth   => :plain # :plain, :login, :cram_md5, the default is no auth
        :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
      }

      or

      Merb::Mailer.config = {:sendmail_path => '/somewhere/odd'}
      Merb::Mailer.delivery_method = :sendmail

You could send mail manually like this (but it‘s better to use a MailController instead).

      m = Merb::Mailer.new :to => 'foo@bar.com',
                           :from => 'bar@foo.com',
                           :subject => 'Welcome to whatever!',
                           :html => partial(:sometemplate)
      m.deliver!

You can use :text option to specify plain text email body and :html for HTML email body.

### Methods

attach deliver! net_smtp new sendmail test_send

### Attributes

mail | [RW] |

### Public Class methods

new(o={})

#### Parameters

o<Hash{~to_s => Object}>: | Configuration commands to send to MailFactory.

### Public Instance methods

attach(file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil, type = nil, headers = nil)

#### Parameters

file_or_files<File, Array[File]>: | File(s) to attach.

filename<String>::

type<~to_s>: | The attachment MIME type. If left out, it will be determined from file_or_files.
headers<String, Array>: | Additional attachment headers.

#### Raises

ArgumentError: | file_or_files was not a File or an Array of File instances.

deliver!()

Delivers the mail with the specified delivery method, defaulting to net_smtp.

net_smtp()

Sends the mail using SMTP.

sendmail()

Sends the mail using sendmail.

test_send()

Tests mail sending by adding the mail to deliveries.

[Validate]