我想从我在 Heroku 上的 Rails 应用程序发送电子邮件。 由于 Heroku 不支持 SMTP,我使用外部 SMTP 服务器。
config/environments/production.rb 有以下几行。
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => "myusername",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
当我从“heroku run console”发送电子邮件时,它工作正常。但它不会从网站发送电子邮件。奇怪的是,“heroku logs --tail”显示“Sent mail to ...”。实际上电子邮件未送达。
有人知道这个问题吗?
谢谢。
三光
最佳答案
你在 config/enviornment.rb 中试过吗
ActionMailer::Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => "myusername",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
关于ruby-on-rails - 使用外部 SMTP 在 Heroku 上发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11754979/