module Roda::RodaPlugins::Mailer::InstanceMethods

def _mail_part(meth, body, headers=nil)

using the given body and optional headers.
Set the text_part or html_part (depending on the method) in the related email,
def _mail_part(meth, body, headers=nil)
  env['roda.mail'].public_send(meth) do
    body(body)
    headers(headers) if headers
  end
  nil
end

def add_file(*a, &block)

can access the attachment via response.mail_attachments.last.
If a block is given, the block is called after the file has been added, and you
Delay adding a file to the message until after the message body has been set.
def add_file(*a, &block)
  response.mail_attachments << [a, block]
  nil
end

def initialize(env)

as the default content_type for the email.
If this is an email request, set the mail object in the response, as well
def initialize(env)
  super
  if mail = env['roda.mail']
    res = @_response
    res.mail = mail
    res.headers.delete(RodaResponseHeaders::CONTENT_TYPE)
  end
end

def no_mail!

Signal that no mail should be sent for this request.
def no_mail!
  throw :no_mail
end