Class: Pakyow::Mailer::Mailer
- Inherits:
-
Object
- Object
- Pakyow::Mailer::Mailer
- Defined in:
- lib/pakyow/mailer/mailer.rb
Instance Method Summary collapse
- #deliver_to(recipient, subject: nil, sender: nil, content: nil, type: nil) ⇒ Object
-
#initialize(config:, renderer: nil, logger: Pakyow.logger) ⇒ Mailer
constructor
A new instance of Mailer.
Constructor Details
Instance Method Details
#deliver_to(recipient, subject: nil, sender: nil, content: nil, type: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pakyow/mailer/mailer.rb', line 15 def deliver_to(recipient, subject: nil, sender: nil, content: nil, type: nil) processed_content = if content process(content, type || "text/plain") elsif @renderer process(@renderer.perform, @config.default_content_type) else {} end html = processed_content[:html] text = processed_content[:text] mail = Mail.new mail.from = sender || @config.default_sender mail.content_type = type || @config.default_content_type mail.delivery_method(@config.delivery_method, @config.) if html.nil? mail.body = text else encoding = @config.encoding mail.html_part do content_type "text/html; charset=" + encoding body html end mail.text_part do content_type "text/plain; charset=" + encoding body text end end if subject mail.subject = subject end Array(recipient).map { |to| deliverable_mail = mail.dup deliverable_mail.to = to deliverable_mail.deliver.tap do |delivered_mail| unless @config.silent log_outgoing(delivered_mail) end end } end |