Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 ActionMailer error - hostname was not match with the server certificate

I am setting up SMTP for my Rails 3 App.

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)

What's wrong?

like image 399
Sam Kong Avatar asked Feb 16 '11 19:02

Sam Kong


2 Answers

Try this in your ActionMailer smtp settings:

: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.

like image 168
Murray Steele Avatar answered Oct 05 '22 06:10

Murray Steele


I had the exact same problem. Solved it by changing 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

like image 26
daz13 Avatar answered Oct 05 '22 05:10

daz13