Email sending function with Action Mailer at the time of new registration


Use ActionMailer to send a welcome email when you register.


Implementation of login function using devise.

Installation procedure

1. Settings to use Action Mailer

The sender of the welcome email is Gmail. Description of how to set ActionMailer in config / environments / development.rb.


Rails.application.configure do


 config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    port:                 587,
    address:              '',
    domain:               '',
    user_name:            'Source address',
    password:             'App password',
    authentication:       :plain,
    enable_starttls_auto: true

For the app password, issue the first 16-digit password with 2-step authentication set, and enter it in the app password. I have referred to the following. -[Get password for Google mail application] ( ・ [How to turn on Google two-step verification] (

2. Create Mailer class

$ rails g mailer UserNotice

3. Edit Mailer class


class UserNoticeMailer < ApplicationMailer
  def send_signup_email(user)
    @user = user
    mail to:, subject: "Membership registration is complete."

4. Create email body


Welcome<%= %>Mr

Thank you for registering for an account.

5. User model editing


#---add to---#

  after_create :send_welcome_mail
  def send_welcome_mail

You can use after_create to call a method to send an email after a new User has been created.

You should now receive a welcome email.

Recommended Posts

Email sending function with Action Mailer at the time of new registration
How to implement the email authentication function at the time of user registration
[Rails 6] Change redirect destination at the time of new registration / login by devise
[Rails 6] Implementation of inquiry function using Action Mailer
[JavaScript] I can't get the response body at the time of error with axios (ajax)
Speed comparison at the time of generation at the time of date conversion
Whether to make the server side at the time of system rebuild with Kotlin or Java
[Android] Exit the activity of the transition source at the time of screen transition
[Rails] Create an email sending function with ActionMailer (complete version)
About the behavior at the time of error of Files.copy (pathA, pathB)
[Rails] Get access_token at the time of Twitter authentication with Sorcery and save it in DB
[Spring Data JPA] Custom ID is assigned in a unique sequence at the time of registration.
Check the actual date and time at parse with Java's SimpleDateFormat
Setting to start multiple units at the same time with Vagrant
[Rails 6] Implementation of new registration function by SNS authentication (Facebook, Google)
[Rails] About Uglifier :: Error: Unexpected token: at the time of deployment
[Illustration] Finding the sum of coins with a recursive function [Ruby]