【发布时间】:2011-05-13 01:37:33
【问题描述】:
我正在使用 Devise :confirmable 和 :recoverable 模块来确认用户并让他在忘记密码时恢复密码。一切正常,邮件生成,我可以在服务器日志中看到它,但是我遇到了错误,邮件没有发送到邮箱。 我的 environment.rb 文件的 SMTP 设置是:
require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true, #this is the important shit!
:address => 'smtp.gmail.com', #'localhost',
:port => 587,
:tls => true,
:domain => 'mail.google.com', # mail.customdomain.com if you use google apps
:authentication => :login,
:user_name => 'jatinkumar.nitk@gmail.com',
:password => '_secret_password'
}
如果 :address 是 'smtp.gmail.com' ,那么我会收到以下错误:
SocketError (getaddrinfo: Name or service not known):
如果我将 :address 设置为“localhost”,则会收到以下错误:
Errno::ECONNREFUSED Connection refused - connect(2)
我不知道这个 :address 是什么意思,所有这些东西的新手。 在运行 uname -a 时,我得到
Linux jatin-ubuntu 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 09:22:14 UTC 2010 i686 GNU/Linux
在我的 /etc/hosts 文件中,条目是:
127.0.0.1 localhost
127.0.1.1 jatin-ubuntu
*#74.125.93.109 smtp.gmail.com
#The above entry added by me*
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
当我取消注释 /etc/hosts 文件中的“smtp.gmail.com”地址时,以下错误消失了:
SocketError (getaddrinfo: Name or service not known):
现在错误是:
Errno::ECONNREFUSED Connection refused - connect(2)
我不知道出了什么问题,用谷歌搜索错误并尝试了所有方法,但没有任何帮助。 我确实安装了 'tlsmail' gem 和 'mail' gem,并且我的应用程序处于开发模式。 帮我解决这个错误,这样我就可以愉快地继续我的 Rails 之旅,如果可能的话,请指导我一点:以正确的方向解决问题,以便我了解这一点的基础知识。 提前致谢
【问题讨论】:
标签: ruby-on-rails smtp localhost devise actionmailer