Rails g mailer template code example

Example 1: preview mailers rails

# located in test/mailers/previews/notifier_mailer_preview.rb

class NotifierPreview < ActionMailer::Preview
  # Accessible from http://localhost:3000/rails/mailers/notifier/welcome
  def welcome
    Notifier.welcome(User.first)
  end
end

Example 2: ruby on rails send activate mail

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'example.com',
  user_name:            '<username>',
  password:             '<password>',
  authentication:       'plain',
  enable_starttls_auto: true }

Tags:

Ruby Example