class Feedigest::MailSender

Attributes

mail_data[R]

Public Class Methods

new(mail_data) click to toggle source
# File lib/feedigest/mail_sender.rb, line 12
def initialize(mail_data)
  @mail_data = mail_data
end

Public Instance Methods

deliver() click to toggle source
# File lib/feedigest/mail_sender.rb, line 16
def deliver
  setup_delivery_method!(mail)
  mail.deliver
end

Private Instance Methods

html_part() click to toggle source
# File lib/feedigest/mail_sender.rb, line 35
def html_part
  Mail::Part.new.tap do |p|
    p.content_type 'text/html; charset=utf-8'
    p.body mail_data.html_body
  end
end
mail() click to toggle source
# File lib/feedigest/mail_sender.rb, line 23
def mail
  return @mail if @mail

  @mail = Mail.new
  @mail.from = mail_data.from
  @mail.to = mail_data.to
  @mail.subject = mail_data.subject
  @mail.html_part = html_part
  @mail.text_part = text_part
  @mail
end
setup_delivery_method!(mail) click to toggle source
# File lib/feedigest/mail_sender.rb, line 49
def setup_delivery_method!(mail)
  mail.delivery_method(:smtp, Feedigest.config.mail_gem_smtp_options)
end
text_part() click to toggle source
# File lib/feedigest/mail_sender.rb, line 42
def text_part
  Mail::Part.new.tap do |p|
    p.content_type 'text/plain; charset=utf-8'
    p.body mail_data.text_body
  end
end