Rails3 中 ActionMailer 的问题。 (ssl 主机名与服务器证书不匹配)

发布于 2024-11-05 04:29:05 字数 7448 浏览 0 评论 0原文

这里有奇怪的错误,我设置了一个邮件程序,在注册我的rails3应用程序后向用户发送确认,它在几天前工作,现在将其移动到另一台服务器并添加不同的其他功能后,我今天再次尝试,我得到了这个错误:

OpenSSL::SSL::SSLError in UsersController#create 
hostname was not match with the server certificate

我的initializers/setup_mail.rb 文件看起来像这样

ActionMailer::Base.delivery_method = :smtp # be sure to choose SMTP delivery
ActionMailer::Base.smtp_settings = {  
  :address              => "mailout.eve-images.de",  
  :port                 => 587,  
  :domain               => "eve-images.de",  
  :user_name            => "xxxxxxx-noreply",  
  :password             => "xxxxxxxx",  
  :authentication       => "plain", 
  :enable_starttls_auto =>  true   
}

我的mailers/user_mailer.rb 文件

class UserMailer < ActionMailer::Base  
  default :from => "[email protected]"  

  def registration_confirmation(user)  
    mail(:to => user.email, :subject => "Registered")  
  end  
end

和我的users_controller

 def create
    @user = User.new(params[:user])
    if @user.save
      UserMailer.registration_confirmation(@user).deliver  
      session[:user_id] = @user.id
      flash[:notice] = "Thank you for signing up! You are now logged in."
      redirect_to "/"
    else
      ....
    end
  end

我已经尝试将 :enable_starttls_auto 设置为 false 并得到相同的错误。 另外我希望我的密码和用户被加密......

任何想法都非常感谢!

如果有帮助的话,这是完整的轨迹跟踪

/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/openssl/ssl-internal.rb:121:in `post_connection_check'
mail (2.2.15) lib/mail/core_extensions/smtp.rb:16:in `tlsconnect'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/smtp.rb:566:in `do_start'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
mail (2.2.15) lib/mail/network/delivery_methods/smtp.rb:127:in `deliver!'
mail (2.2.15) lib/mail/message.rb:1967:in `do_delivery'
mail (2.2.15) lib/mail/message.rb:228:in `block in deliver'
actionmailer (3.0.3) lib/action_mailer/base.rb:401:in `block in deliver_mail'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `instrument'
actionmailer (3.0.3) lib/action_mailer/base.rb:399:in `deliver_mail'
mail (2.2.15) lib/mail/message.rb:228:in `deliver'
app/controllers/users_controller.rb:23:in `create'
actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:151:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.3) lib/active_support/callbacks.rb:435:in `_run__2864349735198625628__process_action__3535857296079828011__callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:120:in `process'
actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in `process'
actionpack (3.0.3) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.3) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in `call'
haml (3.0.25) lib/sass/plugin/rack.rb:41:in `call'
client_side_validations (3.0.4) lib/client_side_validations/middleware.rb:17:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in `call'
activerecord (3.0.3) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.3) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.3) lib/rails/application.rb:168:in `call'
railties (3.0.3) lib/rails/application.rb:77:in `method_missing'
railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

strange error here, I setup an mailer to send a confirmation to the user after signing up in my rails3 app, it worked some days ago, now after moving it to another server and adding different other features i tried it again today and i get this error:

OpenSSL::SSL::SSLError in UsersController#create 
hostname was not match with the server certificate

My initializers/setup_mail.rb file looks like this

ActionMailer::Base.delivery_method = :smtp # be sure to choose SMTP delivery
ActionMailer::Base.smtp_settings = {  
  :address              => "mailout.eve-images.de",  
  :port                 => 587,  
  :domain               => "eve-images.de",  
  :user_name            => "xxxxxxx-noreply",  
  :password             => "xxxxxxxx",  
  :authentication       => "plain", 
  :enable_starttls_auto =>  true   
}

My mailers/user_mailer.rb file

class UserMailer < ActionMailer::Base  
  default :from => "[email protected]"  

  def registration_confirmation(user)  
    mail(:to => user.email, :subject => "Registered")  
  end  
end

and my users_controller

 def create
    @user = User.new(params[:user])
    if @user.save
      UserMailer.registration_confirmation(@user).deliver  
      session[:user_id] = @user.id
      flash[:notice] = "Thank you for signing up! You are now logged in."
      redirect_to "/"
    else
      ....
    end
  end

I tried already to set the :enable_starttls_auto to false and got the same error.
Also I want my pw and user to be encrypted...

Any ideas are really appreciated!

Here is the full strack trace if it helps

/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/openssl/ssl-internal.rb:121:in `post_connection_check'
mail (2.2.15) lib/mail/core_extensions/smtp.rb:16:in `tlsconnect'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/smtp.rb:566:in `do_start'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
mail (2.2.15) lib/mail/network/delivery_methods/smtp.rb:127:in `deliver!'
mail (2.2.15) lib/mail/message.rb:1967:in `do_delivery'
mail (2.2.15) lib/mail/message.rb:228:in `block in deliver'
actionmailer (3.0.3) lib/action_mailer/base.rb:401:in `block in deliver_mail'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `instrument'
actionmailer (3.0.3) lib/action_mailer/base.rb:399:in `deliver_mail'
mail (2.2.15) lib/mail/message.rb:228:in `deliver'
app/controllers/users_controller.rb:23:in `create'
actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:151:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.3) lib/active_support/callbacks.rb:435:in `_run__2864349735198625628__process_action__3535857296079828011__callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:120:in `process'
actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in `process'
actionpack (3.0.3) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.3) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in `call'
haml (3.0.25) lib/sass/plugin/rack.rb:41:in `call'
client_side_validations (3.0.4) lib/client_side_validations/middleware.rb:17:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in `call'
activerecord (3.0.3) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.3) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.3) lib/rails/application.rb:168:in `call'
railties (3.0.3) lib/rails/application.rb:77:in `method_missing'
railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/eveadmin/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

魄砕の薆 2024-11-12 04:29:07

解决方案:

:openssl_verify_mode => 'none' 

solution:

:openssl_verify_mode => 'none' 
悲歌长辞 2024-11-12 04:29:07

用途:

ActionMailer::Base.delivery_method = :sendmail

ActionMailer::Base.delivery_method = :smtp

Use:

ActionMailer::Base.delivery_method = :sendmail

Not

ActionMailer::Base.delivery_method = :smtp
刘备忘录 2024-11-12 04:29:07

我遇到了同样的问题,尽管弗兰克的解决方案对我不起作用。我找到了沿着相同路径的解决方案。

:enable_starttls_auto => false # changed from true

参考:https://gist.github.com/1021285

I had the same problem, though Franks solution didn't work for me. I found a solutions that is along the same path.

:enable_starttls_auto => false # changed from true

reference: https://gist.github.com/1021285

就像说晚安 2024-11-12 04:29:07

对我来说 :enable_starttls_auto => false 不起作用,我把它留下了 :enable_starttls_auto =>;正确。但我犯的错误是,在 devise.rb 中,我没有取消注释这一行:config.mailer = "Devise::Mailer"。当我删除评论时,一切都在我的本地主机上运行。另一方面,当在我托管网站的计算机上时,我仍然收到此错误。

For me :enable_starttls_auto => false didn't worked and I left it :enable_starttls_auto => true. But the thing I had gotten wrong was that in devise.rb I hadn't uncommented this line: config.mailer = "Devise::Mailer". When I removed the comment everything worked on my localhost. On the other hand when on the machine where I host my site I still get this error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文