本文介绍了Rails 3-动作邮件SocketError getaddrinfo没有此类主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已按照
我的外发邮件服务器:mail.xxxx.com(服务器需要身份验证)端口26
My Outgoing Mail Server: mail.xxxx.com (server requires authentication) port 26
并且我在config\environments\development.rb
and i've the following configuration in config\environments\development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "mail.xxxx.com",
:port => 26,
:domain => 'xxxx.com',
:user_name => '[email protected]',
:password => 'dev123',
:authentication => 'login',
# :enable_starttls_auto => true
}
但我总是会出错
SocketError in AuthController#email_sent
getaddrinfo: No such host is known.
Rails.root: E:/RailsApps/training_solutions
Application Trace | Framework Trace | Full Trace
app/controllers/auth_controller.rb:9:in `block in email_sent'
app/controllers/auth_controller.rb:7:in `email_sent'
app/controllers/application_controller.rb:35:in `catch_exceptions'
我没有任何代理人,并且ping时从mail.xxxx.com收到响应。
I'm not behind any proxies, and is getting response from mail.xxxx.com when pinging
我确定从日志中可以正确生成电子邮件,但问题在于发送该电子邮件,请参阅日志文件
I'm sure from the log that email is generated correctly, issue is with the delivery of it, please see the log file
DEPRECATION WARNING: RAILS_ROOT is deprecated. Please use ::Rails.root.to_s. (called from block in <class:Plugin> at E:/RailsApps/training_solutions/vendor/plugins/calendar_date_select/init.rb:11)
DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated: E:/RailsApps/training_solutions/vendor/plugins/validates_captcha/rails/init.rb. (called from <top (required)> at E:/RailsApps/training_solutions/config/environment.rb:6)
DEPRECATION WARNING: ActionController::Routing::Routes is deprecated. Instead, use Rails.application.routes. (called from <top (required)> at E:/RailsApps/training_solutions/config/routes.rb:1)
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/. (called from <top (required)> at E:/RailsApps/training_solutions/config/routes.rb:1)
Started GET "/auth/email_sent?user[email][email protected]&user[username]=Mithun" for 127.0.0.1 at 2011-01-03 12:55:51 +0530
Processing by AuthController#email_sent as HTML
Parameters: {"user"=>{"email"=>"[email protected]", "username"=>"Mithun"}}
[1m[36mSQL (13.0ms)[0m [1mdescribe `events_users`[0m
Mysql::Error: Table 'training_solution.events_users' doesn't exist: describe `events_users`
[1m[35mSQL (4.0ms)[0m describe `attendances_users`
Mysql::Error: Table 'training_solution.attendances_users' doesn't exist: describe `attendances_users`
[1m[36mSQL (4.0ms)[0m [1mdescribe `users_venues`[0m
Mysql::Error: Table 'training_solution.users_venues' doesn't exist: describe `users_venues`
[1m[35mSQL (1.0ms)[0m SHOW TABLES
[1m[36mUser Load (0.0ms)[0m [1mSELECT `users`.* FROM `users` WHERE (`users`.`id` = 85) LIMIT 1[0m
Rendered emailer/welcome_email.html.erb (0.0ms)
Rendered emailer/welcome_email.text.erb (23.0ms)
Sent mail to [email protected] (2524ms)
Date: Mon, 03 Jan 2011 12:55:57 +0530
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Welcome to My Awesome Site
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_4d217a0539050_1bb0299d74473e7";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_4d217a0539050_1bb0299d74473e7
Date: Mon, 03 Jan 2011 12:55:57 +0530
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <[email protected]>
Welcome to example.com, Mithun
===============================================
You have successfully signed up to example.com,
your username is: Mithun.
To login to the site, just follow this link: http://example.com/login.
Thanks for joining and have a great day!
----==_mimepart_4d217a0539050_1bb0299d74473e7
Date: Mon, 03 Jan 2011 12:55:57 +0530
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <[email protected]>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>Welcome to example.com, Mithun</h1>
<p>
You have successfully signed up to example.com,
your username is: Mithun.<br/>
</p>
<p>
To login to the site, just follow this link: http://example.com/login.
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>
----==_mimepart_4d217a0539050_1bb0299d74473e7--
Caught exception! getaddrinfo: No such host is known.
Completed in 3695ms
SocketError (getaddrinfo: No such host is known. ):
app/controllers/auth_controller.rb:9:in `block in email_sent'
app/controllers/auth_controller.rb:7:in `email_sent'
app/controllers/application_controller.rb:35:in `catch_exceptions'
Rendered E:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered E:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (3.0ms)
Rendered E:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (31.0ms)
可能是什么问题
推荐答案
您是否要在邮件发件人的视图中生成任何URL?
Are you trying to generate any urls in your mailer's view?
如果是这样,则需要提供主机。
If so, you'll need to provide a host.
这篇关于Rails 3-动作邮件SocketError getaddrinfo没有此类主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!