# Mailers

Mailers are implemented using the [Quartz-Mailer](https://github.com/amberframework/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: "info@amberframework.org", 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
```