ãRails4ãActionMailerã使ã(heroku ããã¡ã¼ã«ãéä¿¡ãã)
ç°å¢
Rails4.1.8
heroku SendGrid
ç®ç
- productionã¢ã¼ã(heroku)ã§ã¡ã¼ã«ãéããããã«ãã
1. herokuã«ã¢ããªã³ SendGridãã¤ã³ã¹ãã¼ã«
# heroku login # heroku addons:add sendgrid:starter
2. herokuããè¨å®ãåå¾
# heroku config:get SENDGRID_USERNAME # => [email protected] # heroku config:get SENDGRID_PASSWORD # => password
3. herokuã«herokuããè¨å®ãåå¾
# config/environment.rb ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => '[email protected]', :password => 'password', :domain => 'heroku.com', :enable_starttls_auto => true }
4. ãã¼ã«ã«ã§ãã¹ã
# Mailerã¨ãã¦Notiferã¯ã©ã¹ã«test_mailãä½æ # rails g mailer notifier ã§Mailerã追å ã§ãã Notifier.test_mail.deliver