I am setting up SMTP for my Rails 3 App.
我正在为我的Rails 3应用程序设置SMTP。
This configuration works.
这种配置有效。
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
}
But this configuration doesn't. It gives "hostname was not match with the server certificate"
但是这种配置没有。它给出“主机名与服务器证书不匹配”
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
}
Strangely, the same configuration works in Rails 2.3.8. (:tls => true)
奇怪的是,相同的配置在Rails 2.3.8中有效。 (:tls => true)
What's wrong?
怎么了?
3 个解决方案
#1
54
Try this in your ActionMailer smtp settings:
在ActionMailer smtp设置中尝试此操作:
:openssl_verify_mode => 'none'
It gives you a secure connection, but doesn't verify things. Might not be the best idea for a production app, but it works for me.
它为您提供安全连接,但不验证任何事情。可能不是生产应用程序的最佳主意,但它适用于我。
#2
15
I had the exact same problem. Solved it by changing ActionMailer::Base.smtp_settings:
我有同样的问题。通过更改ActionMailer :: Base.smtp_settings解决了这个问题:
:enable_starttls_auto => true
to
至
:enable_starttls_auto => false
and had to make sure :user_name value included the @domain.com
并且必须确保:user_name值包含@ domain.com
#3
0
Are you supplying a default address in your mailer (located in app/mailers)? The last time I recall having this problem, the hostname in my mailer didn't match the hostname in my smtp settings.
您是否在邮件中提供了默认地址(位于app / mailers中)?我最后一次回忆起这个问题,我的邮件程序中的主机名与我的smtp设置中的主机名不匹配。
#1
54
Try this in your ActionMailer smtp settings:
在ActionMailer smtp设置中尝试此操作:
:openssl_verify_mode => 'none'
It gives you a secure connection, but doesn't verify things. Might not be the best idea for a production app, but it works for me.
它为您提供安全连接,但不验证任何事情。可能不是生产应用程序的最佳主意,但它适用于我。
#2
15
I had the exact same problem. Solved it by changing ActionMailer::Base.smtp_settings:
我有同样的问题。通过更改ActionMailer :: Base.smtp_settings解决了这个问题:
:enable_starttls_auto => true
to
至
:enable_starttls_auto => false
and had to make sure :user_name value included the @domain.com
并且必须确保:user_name值包含@ domain.com
#3
0
Are you supplying a default address in your mailer (located in app/mailers)? The last time I recall having this problem, the hostname in my mailer didn't match the hostname in my smtp settings.
您是否在邮件中提供了默认地址(位于app / mailers中)?我最后一次回忆起这个问题,我的邮件程序中的主机名与我的smtp设置中的主机名不匹配。