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']
}
It looks like
address
isnil
.Are your environment variables being read correctly?
Maybe try outputting them in the logger.