在Heroku中配置Sendgrid邮箱

来源:互联网 发布:17173捏脸数据 编辑:程序博客网 时间:2024/05/29 16:13

1.在项目底下输入

heroku addons:create sendgrid:starter(事先需要在Heroku处设置信用卡信息)


在config/environemtns/production.rb下加入以下代码


 config.action_mailer.raise_delivery_errors = true  config.action_mailer.delivery_method = :smtp  host = '<your heroku app>.herokuapp.com'  #修改成你自己的域名  config.action_mailer.default_url_options = { host: host }  ActionMailer::Base.smtp_settings = {    :address        => 'smtp.sendgrid.net',    :port           => '587',    :authentication => :plain,    :user_name      => ENV['SENDGRID_USERNAME'],    :password       => ENV['SENDGRID_PASSWORD'],    :domain         => 'heroku.com',    :enable_starttls_auto => true  }
默认情况下heroku会为我们生产用户名密码,该兴趣的话,可以通过
$ heroku config:get SENDGRID_USERNAME$ heroku config:get SENDGRID_PASSWORD
查询

0 0