Complete the code to generate a new mailer named UserMailer.
rails generate [1] UserMailerIn Rails, to create a mailer, you use rails generate mailer followed by the mailer name.
Complete the mailer method definition to send a welcome email to a user.
def welcome_email(user) @user = user mail(to: @user.email, subject: [1]) end
The subject option in the mail method expects a string for the email subject line.
Fix the error in the mailer view file to correctly display the user's name in the email.
<p>Hello, [1]!</p>In Rails mailer views, use <%= %> to output Ruby code. The instance variable @user holds the user object.
Fill both blanks to set the default sender email and layout in the mailer class.
class UserMailer < ApplicationMailer [1] 'no-reply@example.com' [2] 'mailer' end
Use default from: to set the sender email and layout to specify the mailer layout.
Fill all three blanks to create a mailer method that sends a notification with a subject, recipient, and uses a template.
def notification_email(user) @user = user mail([1]: @user.email, [2]: [3]) end
The mail method takes to: for recipient email and subject: for the email subject string.