Class: MonkeyMailer::Adapters::Smtp
- Inherits:
-
Object
- Object
- MonkeyMailer::Adapters::Smtp
- Defined in:
- lib/monkey-mailer/adapters/smtp.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Smtp
constructor
Options :address => ‘smtp.mandrillapp.com’, :port => 587, :domain => ‘example.com’, :user_name => ‘user’, :password => ‘password’, :authentication => ‘plain’, :enable_starttls_auto => true.
- #send_email(email) ⇒ Object
Constructor Details
#initialize(options) ⇒ Smtp
Options :address => ‘smtp.mandrillapp.com’, :port => 587, :domain => ‘example.com’, :user_name => ‘user’, :password => ‘password’, :authentication => ‘plain’, :enable_starttls_auto => true
15 16 17 18 19 |
# File 'lib/monkey-mailer/adapters/smtp.rb', line 15 def initialize() Mail.defaults do delivery_method :smtp, .inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} end end |
Instance Method Details
#send_email(email) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/monkey-mailer/adapters/smtp.rb', line 21 def send_email(email) Mail.deliver do to "#{email.to_name} <#{email.to_email}>" from "#{email.from_name} <#{email.from_email}>" subject email.subject email..each do || add_file :filename => File.basename(.file_path), :content => File.read(.file_path) end html_part do content_type 'text/html; charset=UTF-8' body email.body end text_part do body email.body.nil? ? '' : email.body.gsub(/<\/?[^>]*>/, "") end end end |