1

So I recently asked a question about sending mail and the error I was getting which is laid out in the link. The answer which I liked, and accepted - seemed to backfire on me and give me the same result, even when I used my own personal, real, non misspelled email address.

The suggestion to put:

begin
  UserMailer.registration_confirmation(@user).deliver
rescue SocketError => e
  # Perhaps you want to log what happened?
  @user.disable(:reason => "Registration mail unable to send: #{e.message}")
end

in the user create action, while good only gave me the same error when I spit out e.message which, in this case, is: "getaddrinfo: nodename nor servname provided, or not known" and I have no idea what this is or even how to fix it.

Does any one have any ideas?

Community
  • 1
  • 1
user3379926
  • 3,855
  • 6
  • 24
  • 42
  • 1
    nodename nor servname provided usually means that you have no connection to the internet (turn off wifi and try to pull from git to see this error). How are you adding credentials to the mailer? – nort Jul 05 '14 at 03:51
  • The credentials, as shown in the link that links to the original question, are added via a "ignored" application.yml file in which the gem fiagro is used to fetch environment variables. I have tested to make sure the appropriate creds are being entered and I can assure you they are. As for the internet issue that seems off, because as we speak I am wirelessly connected on my mac responding to you oO – user3379926 Jul 05 '14 at 03:59

1 Answers1

1

SMTP

Seems like a relatively common issue (considering what it says); I would surmise the issue is that your UserMailer is unable to either:

  • connect to the SMTP server provided
  • you don't have Internet connectivity
  • you've got an issue with the declaration of the SMTP server details

The main issue I can see is you've called an initializer. This might not be any problem, but the way we set the SMTP settings is inside the application.rb, or relevant environment files:

  #config/environments/development.rb
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :domain               => "domain.com",
      :user_name            => "testestetst@gmail.com",
      :password             => Rails.application.secrets.gmail,
      :authentication       => :plain,
      :enable_starttls_auto => true
  }
  config.action_mailer.default_url_options = {
      :host => "lvh.me:3000"
  }
Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147