Class: Goodmail::Mailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- Goodmail::Mailer
- Defined in:
- lib/goodmail/mailer.rb
Overview
Internal Mailer class. Inherits from ActionMailer::Base to provide the necessary context for building Mail::Message objects, but without relying on any host application views or layouts.
Instance Method Summary collapse
-
#compose_message(headers, html_body, text_body, unsubscribe_url, dsl_attachments = []) ⇒ Object
This instance method acts as the mailer action.
Instance Method Details
#compose_message(headers, html_body, text_body, unsubscribe_url, dsl_attachments = []) ⇒ Object
This instance method acts as the mailer action. It’s called via Goodmail::Mailer.compose_message(…) Action Mailer wraps the result in a MessageDelivery object.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/goodmail/mailer.rb', line 19 def ( headers, html_body, text_body, unsubscribe_url, = [] ) headers = headers.dup goodmail_add_list_unsubscribe_headers!(headers, unsubscribe_url) () # Attachments must be registered before `mail` materializes the message; # the block form below lets Rails build the multipart/alternative tree. # Sources: # - late attachments raise: # https://github.com/rails/rails/blob/debbd18c562df17d01944c475e9291d927910b58/actionmailer/lib/action_mailer/base.rb#L766-L781 # - block-form `mail` with direct plain/html rendering: # https://github.com/rails/rails/blob/debbd18c562df17d01944c475e9291d927910b58/actionmailer/lib/action_mailer/base.rb#L851-L873 mail(headers) do |format| format.text { render plain: text_body.to_s } format.html { render html: html_body.to_s.html_safe } end end |