"Connection refused - connect(2) for nil port 587" delivering mails from Sidekiq in staging

1.7k views Asked by At

I tried to send many user emails from a worker using Sidekiq but when I enqueued the worker I got an error Connection refused - connect(2) for nil port 587, doing the same process on localhost works fine.

Piece of worker code

def send_mails(users)
  users.each do |user|
     WelcomeMailer.presale_users({email: user.email}).deliver
  end
end

staging.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: ENV['SES_ADDRESS'],
  port: 587,
  domain: 'domain.com',
  user_name: ENV['SES_USER_NAME'],
  password: ENV['SES_PASSWORD']
}
1

There are 1 answers

1
Max Woolf On

It looks like address is nil.

Are your environment variables being read correctly?

Maybe try outputting them in the logger.