Mailers: templates & async
This course walks through the three mailers in one Rails app and how their emails get sent. Each mailer has an HTML and a plain-text template, which Action Mailer sends as one multipart email. The lessons cover passing data with .with(...), setting default_url_options per environment, and choosing between deliver_later and deliver_now. They then follow the queued jobs into Solid Queue, its database setup and its workers. The last part looks at config/recurring.yml and the scheduled tasks it runs in production.
What you'll learn
- ✓How Action Mailer sends multipart emails from paired HTML and text templates
- ✓Passing data into a mailer with .with(...) and reading it through params
- ✓Setting default_url_options so a mailer can build absolute URLs
- ✓When to use deliver_later and when deliver_now
- ✓How Solid Queue stores jobs in database tables and runs them in workers
- ✓Scheduling recurring tasks with config/recurring.yml
Three mailers, each with an HTML and a text template
app/mailers/auth/password_mailer.rb:
Read the full lesson free →Curriculum
7 lessonsThree mailers, each with an HTML and a text template
The app's three mailers, their shared ApplicationMailer base, layouts, and paired templates that produce multipart emails.
with(...): how this app passes data into a mailer
How .with(...) turns keyword arguments into a params hash, and why positional calls fail against zero-parameter actions.
default_url_options: building a URL with no request behind it
Why a mailer needs default_url_options to build absolute URLs, set with a different host in each environment.
deliver_later vs deliver_now: where this app uses each
Requests use deliver_later to avoid waiting on the mail server, while EmailJob uses deliver_now to handle failures.
Solid Queue: where deliver_later's jobs go
Where deliver_later jobs go: Solid Queue tables, a separate queue database in development and test, and its workers.
recurring.yml: Solid Queue's scheduled tasks, running in production
The three production tasks in config/recurring.yml, its class and command forms, and its two schedule styles.
Putting it together: from a .with(...) call to a running worker
One path from a .with(...) call to a Solid Queue worker, linking the earlier lessons, plus a small Ruby challenge.