class MonkeyMailer::Adapters::Smtp
Public Class Methods
new(options)
click to toggle source
Options :address => ‘smtp.mandrillapp.com’, :port => 587, :domain => ‘example.com’, :user_name => ‘user’, :password => ‘password’, :authentication => ‘plain’, :enable_starttls_auto => true
# File lib/monkey-mailer/adapters/smtp.rb, line 15 def initialize(options) Mail.defaults do delivery_method :smtp, options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} end end
Public Instance Methods
send_email(email)
click to toggle source
# 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.attachments.each do |attachment| add_file :filename => File.basename(attachment.file_path), :content => File.read(attachment.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