新手问题 邮件发送失败

mydavidowen · 2012年08月11日 · 最后由 mydavidowen 回复于 2012年08月13日 · 3579 次阅读

新手。看 agile web development with rails 3.2 时,卡在了发邮件的这一章,百度,google 无果,求助!

environment 里的设置:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "gmail.com",
    authentication: "plain",
    user_name: "[email protected]",
    password: "password",
    enable_starttls_auto: true
}

log 报错:

Completed 500 Internal Server Error in 2498ms

Errno::ECONNREFUSED (No connection could be made because the target machine actively refused it. - connect(2)):
  app/controllers/orders_controller.rb:60:in `block in create'
  app/controllers/orders_controller.rb:56:in `create'

自己顶一下。。。没人有线索吗?

mailer 配置没错,或许是其他问题,app/controllers/orders_controller.rb line60 是怎么写的?

换个邮件服务器试试

我也刚看完这一章,书上有一段话没怎么懂 The :sendmail setting delegates mail delivery to your local system’s sendmail program, which is assumed to be in /usr/sbin. This delivery mechanism is not particularly portable, because sendmail is not always installed in this directory on different operating systems. It also relies on your local sendmail supporting the -i and -t command options.

are you using linux or mac os ? but as i think ,you should review something at there: http://rubygems.org/search?utf8=%E2%9C%93&query=smtp

try to use some smtp client of ruby.

good luck

#2 楼 @yorzi 60 行是 OrderNotifier.received(@order).deliver class OrderNotifier < ActionMailer::Base 中 def received(order) @order = order mail to: "[email protected]" end

#3 楼 @nevernet 换成 address: "smtp.126.com", port: 25, domain: "126.com", authentication: "plain", user_name: "[email protected]", password: "password" 一样的错误

需要 登录 后方可回复, 如果你还没有账号请 注册新账号