我正在为我的 Rails 3 应用程序设置 SMTP。
此配置有效。
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "<username>",
:password => "<password>",
:authentication => "plain",
:enable_starttls_auto => true
}
但是这个配置没有。
它给出“主机名与服务器证书不匹配”
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "some_other_server.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "<username>",
:password => "<password>",
:authentication => "plain",
:enable_starttls_auto => true
}
奇怪的是,相同的配置适用于 Rails 2.3.8。 (:tls => 真)
怎么了?
最佳答案
在你的 ActionMailer smtp 设置中试试这个:
:openssl_verify_mode => 'none'
它为您提供安全连接,但不会验证事物。对于生产应用程序来说,这可能不是最好的主意,但它对我有用。
关于ruby-on-rails - Rails 3 ActionMailer 错误 - 主机名与服务器证书不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5021416/