Documentation

Mailers

Browse documentation

Read this page as HTML, Markdown, or structured JSON—or open the published Markdown with an AI assistant. Gemini receives the prompt through your clipboard because its signed-out page does not reliably prefill URL text; paste when the new tab opens. External assistants need the public site URL.

Mailers

Mailers are implemented using the Quartz-Mailer library. This library is required by default within config/mailer.cr.

Define a Mailer

The mailer has the ability to set the from, to, cc, bcc, and subject as well as both text and html body formats. You may use the render helper to create the body of the email.

Crystal
class WelcomeMailer < Quartz::Composer
  def sender
    address email: "[email protected]", name: "Amber"
  end

  def initialize(name : String, email : String)
    to email: email, name: name # Can be called multiple times to add more recipients

    subject "Welcome to Amber"

    text render("mailers/welcome_mailer.text.ecr")
    html render("mailers/welcome_mailer.html.slang", "mailer-layout.html.slang")
  end
end

Deliver an Email

Crystal
WelcomeMailer.new(name, email).deliver