Jirapong (owner)

Revisions

gist: 205641 Download_button fork
public
Public Clone URL: git://gist.github.com/205641.git
Embed All Files: show embed
actionmailer without rails #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# for this example the folder structure should be as follow
#
# --+ mailer
# |-- image.jpg
# |-- mailer.rb (this file)
# |--+ notifier
# |-- email.rhtml
 
require 'rubygems'
require 'action_mailer'
 
class Notifier < ActionMailer::Base
  def email()
    recipients "receiver@domain.com"
    from "sender@anotherdomain.com"
    subject "Subject"
    content_type "multipart/alternative"
    
    body = { :first_name => "John", :last_name => "Doe"}
    part :content_type => "text/plain", :body => render_message('email', body)
    attachment :content_type => "image/jpeg", :body => File.read("image.jpg")
  end
end
 
Notifier.template_root = File.dirname(__FILE__)
 
Notifier.smtp_settings = {
  :address => "smtp.mailserver.com",
  :port => 25,
  :user_name => "sender@anotherdomain.com",
  :password => "password",
  :authentication => :login
}
 
Notifier.deliver_email