Rails不通过Mandrillapp发送邮件(提供节点名称或服务名称)

时间:2018-05-23 10:40:56

标签: ruby-on-rails actionmailer mandrill

我遇到了这个问题:

SocketError in Front::RequestsController#create

getaddrinfo: nodename nor servname provided, or not known
Extracted source (around line #539):

#537 
#538     def tcp_socket(address, port)
*539       TCPSocket.open address, port
#540     end
#541 
#542     def do_start(helo_domain, user, secret, authtype)

尝试通过Mandrillapp本地发送邮件时。这是我的development.rb文件:

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true 

  config.action_mailer.delivery_method = :smtp

  # Specify what domain to use for mailer URLs 

  config.action_mailer.smtp_settings = {
    user_name: 'my_user_name',
    password: 'my_password',
    domain: 'localhost:3000',
    address: 'smtp.mandrillapp.com"',
    port: 587,
    authentication: :plain,
    enable_starttls_auto: true
  }

在生产中,即使通过Figaro(application.yml)加载这些变量,一切也能正常工作。但是,在开发模式下,我遇到了上面提供的问题。

我尝试了不同的端口,不同的设置......在开发上没有任何作用。有人能指出我至少是正确的调试方向吗?大多数SO答案,如this都没有帮助。

1 个答案:

答案 0 :(得分:1)

根据共享的详细信息,似乎您在指定smtp设置时在地址键中添加了额外的引号,并且在尝试连接到地址时显示此错误:

当前设置

config.action_mailer.smtp_settings = {
 user_name: 'my_user_name',
 password: 'my_password',
 domain: 'localhost:3000',
 address: 'smtp.mandrillapp.com"',
 port: 587,
 authentication: :plain,
 enable_starttls_auto: true
}

更新设置:

config.action_mailer.smtp_settings = {
 user_name: 'my_user_name',
 password: 'my_password',
 domain: 'localhost:3000',
 address: 'smtp.mandrillapp.com',
 port: 587,
 authentication: :plain,
 enable_starttls_auto: true
}