Rails 3 - 动作邮件程序SocketError getaddrinfo没有这样的主机是已知的

时间:2011-01-03 07:39:21

标签: ruby-on-rails email ruby-on-rails-3 actionmailer

我已根据http://edgeguides.rubyonrails.org/action_mailer_basics.html

配置了动作邮件程序

我的外发邮件服务器:mail.xxxx.com(服务器要求身份验证)端口26

我在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            => 'dev@xxxx.com',
    :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的回复

我确信从日志中正确生成了电子邮件,问题在于发送,请参阅日志文件

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]=mithun@xxxx.com&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"=>"mithun@xxxx.com", "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 mithun@xxxx.com (2524ms)
Date: Mon, 03 Jan 2011 12:55:57 +0530

From: dev@xxxx.com

To: mithun@xxxx.com

Message-ID: <4d217a057af0f_1bb0299d7447683@Mithun-PC.mail>

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: <4d217a055bb08_1bb0299d74474d4@Mithun-PC.mail>



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: <4d217a056d064_1bb0299d74475e9@Mithun-PC.mail>



<!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)

可能是什么问题

1 个答案:

答案 0 :(得分:1)

您是否尝试在邮件程序中生成任何网址?

如果是这样,您需要提供主持人。

Generating URLs in Action Mailer Views