Skip to main content

Prerequisites

Before you start, you’ll need:

Guide

1

Setup your environment

Add these lines of code into your environment config file.
config/environments/environment.rb
2

Send email using Rails Action Mailer

Then create a UserMailer class definition.
app/mailers/user_mailer.rb
And create your ERB email template.
app/views/user_mailer/welcome_email.html.erb
Initialize your UserMailer class. This returns an ActionMailer::MessageDelivery instance.
Finally, you can now send emails using the deliver_now! method:

Examples

Rails SMTP Example

See the full source code.