Firstly, we need to specify sender and recipient(s) and the subject of the email. For this purpose a mailer exposes three mandatory methods: , .to
, .subject
and two optional: .cc
, .
They all accept a string, but .to
can also accept an array of strings in order to set multiple recipients.
Both .from
and .to
MUST be specified when we deliver an email.
You may have noticed that have a hardcoded value can be useful to set the sender, but it doesn’t work well for the rest of the details.
If you pass a symbol as an argument, it will be interpreted as a method that we want to use for that information.
There is NOT a convention between the name of the methods and their corresponding DSL.
In the previous section, we have referenced an variable, where does it come from? Similarly to a , a mailer can have a set of locals that can be passed as an argument in order to make them available during the rendering.
We can specify as many locals as we want, the key that we use for each of them it’s the same that we use to reference that object. For instance, we passed :user
key, and we can use user
in the mailer and its associated templates.
The following keys for locals are RESERVED: :format
and .