Ruby on rails 仅在生产中出现邮件错误
设置:带有Ubuntu 12.04、Apache、PhusionPassenger、Rail 3.2.12、Postgresql的VPS 我想用我的应用程序发送确认邮件。在开发模式下,一切正常,用户收到一封邮件,但在生产中,我收到以下错误(日志): 所以我想,错误应该出现在时事通讯_controller.rb中(第45行已标记): 时事通讯Ruby on rails 仅在生产中出现邮件错误,ruby-on-rails,ruby-on-rails-3,ubuntu-12.04,production-environment,mailer,Ruby On Rails,Ruby On Rails 3,Ubuntu 12.04,Production Environment,Mailer,设置:带有Ubuntu 12.04、Apache、PhusionPassenger、Rail 3.2.12、Postgresql的VPS 我想用我的应用程序发送确认邮件。在开发模式下,一切正常,用户收到一封邮件,但在生产中,我收到以下错误(日志): 所以我想,错误应该出现在时事通讯_controller.rb中(第45行已标记): 时事通讯 class NewsletterMailer < ActionMailer::Base default from: "some@email.com
class NewsletterMailer < ActionMailer::Base
default from: "some@email.com"
def confirmation(email)
mail to: email,
subject: "Welcome"
end
end
对于邮件,我使用带有mandrill或gmail的smtp。Gmail设置在另一个应用程序中运行良好
我的环境.rb
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
LandingPage::Application.initialize!
LandingPage::Application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587, # or 25
:enable_starttls_auto => true, # detects and uses STARTTLS
:user_name => "user",
:password => "password",
:authentication => 'login' # Mandrill supports 'plain' or 'login'
}
end
更新:
我发现提交的内容保存在我的索引中。所以我想DB是有效的
有什么建议吗?谢谢我通过将mandrill更改为新的passwort(api密钥)解决了我的问题。仍然不知道问题出在哪里,因为旧的是在开发模式下工作的 工作环境:
YourApp::Application.configure do
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:enable_starttls_auto => true,
:user_name => "MANDRILL_USERNAME",
:password => "MANDRILL_PASSWORD", # SMTP password is any valid API key
:authentication => 'login'
}
你能在生产中连接到数据库吗?如果您尝试在控制台中手动创建
时事通讯
,会发生什么情况?如果我提交,电子邮件会保存在我的数据库中,我会在索引中看到它们。所以我猜这和数据库有联系……是的,这表明问题在于邮件设置。您可以添加这些吗?好的,谢谢,我在我的帖子中添加了设置您的环境/development.rb
文件中有任何与邮件相关的设置吗?我猜production.rb
中的某些内容正在覆盖您的environment.rb
设置。
production:
adapter: postgresql
encoding: unicode
reconnect: false
database: app_production
pool: 5
username: user
password: secret
host: localhost
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
LandingPage::Application.initialize!
LandingPage::Application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587, # or 25
:enable_starttls_auto => true, # detects and uses STARTTLS
:user_name => "user",
:password => "password",
:authentication => 'login' # Mandrill supports 'plain' or 'login'
}
end
YourApp::Application.configure do
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:enable_starttls_auto => true,
:user_name => "MANDRILL_USERNAME",
:password => "MANDRILL_PASSWORD", # SMTP password is any valid API key
:authentication => 'login'
}