Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WelcomeEmail < ApplicationMailer
- def welcome_email(user)
- @user = user
- mail to: @user.email, subject: "Thanks for joining!", from: "info@app.com"
- end
- end
- class User < ApplicationRecord
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :validatable, :confirmable
- def after_confirmation
- WelcomeEmail.welcome_email(self).deliver
- end
- end
- <h1>This is the welcome email!</h1>
- Rails.application.configure do
- config.action_mailer.perform_deliveries = true
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
- config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
- end
- Rails.application.configure do
- # for emails to go out
- config.action_mailer.default_url_options = { host: 'appname.herokuapp.com', protocol: 'https' }
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.perform_deliveries = true
- config.action_mailer.smtp_settings = {
- :user_name => ENV['SENDGRID_USERNAME'],
- :password => ENV['SENDGRID_PASSWORD'],
- :domain => 'herokuapp.com',
- :address => 'smtp.sendgrid.net',
- :port => 587,
- :authentication => :plain,
- :enable_starttls_auto => true
- }
- end
Add Comment
Please, Sign In to add comment