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.
1
class WelcomeMailer < Quartz::Composer
2
def sender
3
address email: "[email protected]", name: "Amber"
4
end
5
6
def initialize(name : String, email : String)
7
to email: email, name: name # Can be called multiple times to add more recipients
8
9
subject "Welcome to Amber"
10
11
text render("mailers/welcome_mailer.text.ecr")
12
html render("mailers/welcome_mailer.html.slang", "mailer-layout.html.slang")
13
end
14
end
Copied!

Deliver an Email

1
WelcomeMailer.new(name, email).deliver
Copied!
Last modified 2yr ago