Search code examples
ruby-on-railsactionmailermandrill

Rails not sending mails in development via Mandrillapp (nodename nor servname provided)


I'm running into this issue:

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)

When trying to send mails via Mandrillapp locally. This is my development.rb file:

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
  }

On production everything works fine, even when loading those variables via Figaro (application.yml). However, on development mode, I'm running into the issue provided above.

I tried different ports, different settings... Nothing works on development. Could someone point me, at least, into the right debugging direction? Most SO-answers, like this doesn't help at all.


Solution

  • As per the details shared it seems there you have added an extra quote in address key when specifying smtp settings and when trying to connect to address it is showing this error:

    Current Setting

    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
    }
    

    Update Setting:

    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
    }