繁体   English   中英

在轨道上配置Mandril Heroku Ruby

[英]Configuration Mandril Heroku Ruby on rails

我已经尝试了很长时间为heroku配置邮件发件人了,sendgrid无法实现,现在我正在尝试使用Mandril。 它说我必须放这段代码,但是我不知道在哪里,有人建议吗?

require 'mandrill'
m = Mandrill::API.new # All official Mandrill API clients will automatically pull your API key from the environment
rendered = m.templates.render 'MyTemplate', [{:name => 'main', :content => 'The main content block'}]
puts rendered['html'] # print out the rendered HTML

这是我的日志:

2015-06-17T01:01:50.949397+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
2015-06-17T01:01:50.949399+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
2015-06-17T01:01:50.949400+00:00 app[web.1]: 
2015-06-17T01:01:50.949402+00:00 app[web.1]: 
2015-06-17T01:01:50.957251+00:00 heroku[router]: at=info method=POST path="/users/password"

环境/生产

}

ActionMailer::Base.smtp_settings = {
    :port =>           '587',
    :address =>        'smtp.mandrillapp.com',
    :user_name =>      ENV['mandrilusername'],
    :password =>       ENV['mandrilpass'],
    :domain =>         'heroku.com',
    :authentication => :plain
}
ActionMailer::Base.delivery_method = :smtp

end

这里有什么错误

这是我配置ActionMailer以通过Heroku上的Mandrill发送的方式。 将其粘贴在您的config / environments / production.rb(或适用于Heroku实例的适当环境)中:

# Send emails through Mandrill
config.action_mailer.default_url_options = { :host => 'example.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: 'smtp.mandrillapp.com',
  port: 587,
  domain: 'example.com',
  user_name: ENV['MANDRILL_USERNAME'],
  password: ENV['MANDRILL_PASSWORD']
}

然后从命令行设置两个环境变量:

heroku config:set MANDRILL_USERNAME=myusername
heroku config:set MANDRILL_PASSWORD=mypassword

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM