Devise doesn't send confirmation email after registration in production environment

1,098 views
Skip to first unread message

Tsvetelina Borisova

unread,
Apr 9, 2012, 3:25:10 PM4/9/12
to plataforma...@googlegroups.com
Hello,
      can someone help me with this problem. In development environment everything works fine. But in production it doesn't. I have this in production.rb:

    config.action_mailer.default_url_options = { :host => 'mydomain.com:4002' }
   
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "mydomain.com",
    :authentication => :login,
    :user_name => "mydo...@gmail.com",
    :password => "pass",
    :enable_starttls_auto => false, - I read that some people saying that it should be true but others say it should be false
    }
#config.action_mailer.raise_delivery_errors = false - tried it with true but didn't work
  config.action_mailer.perform_deliveries = true
 
And I have this line in devise.rb:
  config.mailer_sender = "mydo...@gmail.com"

And I have this in routes.rb:
  default_url_options :host => "mydomain.com:4002"

And in the log file I see that email is send and this error:
OpenSSL::SSL::SSLError (hostname was not match with the server certificate):

but in my mail box I don't have the sended message. Even the generated confirmation link is not correct when I go to it.
I am using rails 3.0.0, ruby 1.8.7. and devise 1.1.3. Thanks in advance to anyone who can help me :)

Tsvetelina Borisova

unread,
Apr 9, 2012, 3:37:38 PM4/9/12
to plataforma...@googlegroups.com
Sorry for the same topic. I thought that I haven't press Enter to publish the subject

Carlos Antonio da Silva

unread,
Apr 9, 2012, 3:39:48 PM4/9/12
to plataforma...@googlegroups.com
No problem. New messages are usually approved before being sent to the list, unless the user has already sent something - or we clicked the wrong approve button before :P

-- 
At.
Carlos Antonio

Tsvetelina Borisova

unread,
Apr 9, 2012, 4:54:23 PM4/9/12
to plataforma...@googlegroups.com
So I found a solution to my problem. I found an article on this site:http://dev.nuclearrooster.com/2007/12/12/creating-a-ruby-gem-for-smtp_tls/

that has this:

As you may know, the Ruby 1.8.* Net::SMTP library does not allow for TLS (SSL) connections. This prevents you from connecting to Gmail, or other mail servers that require a secure connection. Fortunatly, there is a pretty tight bit of code to fix this problem. As far as I can tell, this code originated at a japanese site. This code is all over, if you search for 'SMTP_TLS ruby.'

Great! We have the code! This is actually one of my favorite examples of the open source community. I originally got this code from a guy in Russia, who translated the Japanese page above. Pretty cool. Anyway, I don't really want to paste this code above every script I write that sends out an email. What about a gem!

UPDATE (12/18/07): Well it turns out there already is a gem for this. TLS Mail is not exactly the same as above, but it does the trick. The code in this gem is the code in the Ruby 1.9 source. The only catch is that you have to enable the TLS protocol before you send the mail:

Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)

Grab the code with "sudo gem install tlsmail"

I added the line in production.rb and together with the configurations that I already had it worked! :)

09 април 2012, понеделник, 22:25:10 UTC+3, Tsvetelina Borisova написа:

Tsvetelina Borisova

unread,
May 30, 2012, 3:49:53 PM5/30/12
to plataforma...@googlegroups.com
This gem - tlsmail will give you warning that SMTP, POP are already initialized. Since on the project I am working on this was not good I had to remove it. 
Reply all
Reply to author
Forward
0 new messages