Guest User

Untitled

a guest
Feb 16th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. class WelcomeEmail < ApplicationMailer
  2.  
  3. def welcome_email(user)
  4. @user = user
  5. mail to: @user.email, subject: "Thanks for joining!", from: "info@app.com"
  6. end
  7.  
  8. end
  9.  
  10. class User < ApplicationRecord
  11. devise :database_authenticatable, :registerable,
  12. :recoverable, :rememberable, :validatable, :confirmable
  13.  
  14. def after_confirmation
  15. WelcomeEmail.welcome_email(self).deliver
  16. end
  17.  
  18. end
  19.  
  20. <h1>This is the welcome email!</h1>
  21.  
  22. Rails.application.configure do
  23.  
  24. config.action_mailer.perform_deliveries = true
  25. config.action_mailer.delivery_method = :smtp
  26. config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
  27. config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  28.  
  29. end
  30.  
  31. Rails.application.configure do
  32. # for emails to go out
  33. config.action_mailer.default_url_options = { host: 'appname.herokuapp.com', protocol: 'https' }
  34. config.action_mailer.delivery_method = :smtp
  35. config.action_mailer.perform_deliveries = true
  36. config.action_mailer.smtp_settings = {
  37. :user_name => ENV['SENDGRID_USERNAME'],
  38. :password => ENV['SENDGRID_PASSWORD'],
  39. :domain => 'herokuapp.com',
  40. :address => 'smtp.sendgrid.net',
  41. :port => 587,
  42. :authentication => :plain,
  43. :enable_starttls_auto => true
  44. }
  45. end
Add Comment
Please, Sign In to add comment