Class: Mailer
- Inherits:
-
Object
- Object
- Mailer
- Defined in:
- lib/mailer.rb
Instance Method Summary collapse
-
#initialize(username, password) ⇒ Mailer
constructor
A new instance of Mailer.
- #send(to_, cc_, from_, subject_, body_) ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Mailer
Returns a new instance of Mailer.
4 5 6 7 |
# File 'lib/mailer.rb', line 4 def initialize(username, password) @username = username @password = password end |
Instance Method Details
#send(to_, cc_, from_, subject_, body_) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mailer.rb', line 9 def send(to_, cc_, from_, subject_, body_) = {:address => "smtp.gmail.com", :port => 587, :user_name => @username, :password => @password, :authentication => 'plain', :enable_starttls_auto => true} mail = Mail.new do delivery_method :smtp, to to_ cc cc_ from from_ subject subject_ end html_part = Mail::Part.new do content_type 'text/html; charset=UTF-8' body "#{body_}\n #{File.read('email_footer.html')}" end mail.html_part = html_part mail.deliver end |