Rails Puma邮件Erro端口为ni

时间:2017-07-21 12:55:38

标签: ruby-on-rails email

错误:

*telnet smtp.gmail.com 587 ok
telnet smtp.gmail.com 25 ok
Connection refused - connect(2) for nil port 2

配置:

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'gmail.com',
  user_name:            'rapid.virus.0@gmail.com',
  password:             '55xxxxxx',
  authentication:        :plain,
  enable_starttls_auto: true
}

1 个答案:

答案 0 :(得分:1)

有两件事可以帮助您解决“拒绝连接”问题

  • whatismyip.com找到你的IP,然后把它放到这一行,(gmail不能接受localhost:3000)

配置/环境/ development.rb

config.action_mailer.default_url_options = { :host => 'xxx.xxx.xxx.xxx' }