我有一个rails应用程序,我在其中构建了一个联系表单。 它在本地使用此配置:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
end
现在我想使用Mandrill让它在Heroku上运行,所以这是我的production.rb
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => ENV["MANDRILL_USERNAME"],
:password => ENV["MANDRILL_APIKEY"]
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'myDomain.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
当我访问网站时,填写表格并点击“发送”,这是日志:
2014-04-07T23:35:56.661073 + 00:00 app [web.1]:处理方式 ContatoController#create as HTML 2014-04-07T23:35:56.661073 + 00:00 app [web.1]:参数:{“utf8”=>“???”,“auth enticity_token “=>” 中”, “contato”=> {“name”=>“test1”,“email”=>“myEmail@email.com”, “message”=>“sdfsdffsd”,“nickname”=>“”},“commit”=>“发送”} 2014-04-07T23:35:56.661073 + 00:00 app [web.1]:参数: {“utf8”=>“???”,“auth enticity_token “=>” 中5769b554vJsVK3KldK / EmSaN8yUF / z4S7LZdzSlZ6XE =”, “contato”=> {“name”=>“test1”,“email”=>“myEmail@email.com”, “message”=>“sdfsdffsd”,“nicknam e”=>“”},“commit”=>“发送”} 2014-04-07T23:35:56.668905 + 00:00 app [web.1]:已呈现 供应商/束/红宝石/ 1.9.1 /gems/mail_form-1.5.0/lib/mail_form/views/mail_form/contact.erb (1.1ms)2014-04-07T23:35:56.668905 + 00:00 app [web.1]:已呈现 供应商/束/红宝石/ 1.9.1 /gems/mail_form-1.5.0/lib/mail_form/views/mail_form/contact.erb (1.1ms)2014-04-07T23:35:58.200457 + 00:00 app [web.1]: 2014-04-07T23:35:58.200457 + 00:00 app [web.1]:发送邮件到 myEmail@gmail.com(153 0.1ms)2014-04-07T23:35:58.200457 + 00:00 app [web.1]:2014-04-07T23:35:58.200457 + 00:00 app [web.1]:发送邮件到 myEmail@gmail.com(153 0.1ms)2014-04-07T23:35:58.209656 + 00:00 heroku [router]:at = info method = POST path = / conta to host = myDomain.com request_id = b3b2f599-a685-4968-97a1-9dd7a3508083 fwd =“20 1.37.139.250“dyno = web.1 connect = 2ms service = 1558ms status = 200 bytes = 6107
但电子邮件永远不会到来。 Mandril不算作发送的电子邮件。
因为我使用的是通知电子邮件“来自地址”,所以我更改为no-reply@myDomain.com并将其添加到mandrill的发送域列表中。但仍然没有任何反应。
可能导致此错误的原因是什么?
答案 0 :(得分:0)
发现它:不知何故,我在heroku配置中的Mandrill键与Mandrill网站上给出的不一样,并没有显示错误。我配置了正确的密钥,现在可以正常工作。