Why email is not sent with ActiveJob?

I am currently updating the application to Rails 4.2, so we can use the ActionMailer method deliver_later. Everything works great in development. When I deploy to our staging server using a gem capistrano-sidekiq, emails are not displayed. Based on this log, it seems that the task has been queued and completed correctly.

Ubuntu 14.04 server with redis installed using apt-get.

[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 51ddade2-4689-40fd-aeda-7e94f7260e43) to Sidekiq(mailers) with arguments: 
"ApplicationMailer", "admin_message", "deliver_now", "Broken Link", "Testing an email from staging."
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43] Performing ActionMailer::DeliveryJob from Sidekiq(mailers) 
with arguments: "ApplicationMailer", "admin_message", "deliver_now", "Broken Link", "Testing an email from staging."
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43]   Rendered application_mailer/admin_message.html.erb within  layouts/mailer (1.9ms)
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43]   Rendered layouts/mailer.html.erb (8.8ms)
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43]   Rendered application_mailer/admin_message.text.erb within layouts/mailer (0.8ms)
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43]   Rendered layouts/mailer.text.erb (3.6ms)
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43]
Sent mail to email-testing@loamstudios.com (216.8ms)
[ActiveJob] [ActionMailer::DeliveryJob] [51ddade2-4689-40fd-aeda-7e94f7260e43] Performed ActionMailer::DeliveryJob from Sidekiq(mailers) in 796.8ms

I checked if sidekiq works with ps aux | [sS]idekiq, and there is a record:

deploy   15104  0.4  7.4 972692 152452 ?       Sl   10:07   0:03 sidekiq 3.5.1 sustainabilityassessment_staging [0 of 25 busy]

I also ensured that the mail queue exists with set :sidekiq_queue, ["default", "mailers"]in my deploy.rb.

My mailer method:

def admin_message(subject, message)
    @message = message
    mail(to: "<address>", subject: subject)
  end

Any idea what is going on or what can I fix after?

: . sidekiq, RAILS_ENV=staging bundle exec sidekiq -q mailers -q default appname/current, . , , , - , capistrano-sidekiq sidekiq.

: sidekiq , , - . , . ...

: config.action_mailer.raise_delivery_errors = false config/environments/staging.rb, . , :

Net::SMTPServerBusy: 454 4.7.1 <email address>: Relay access denied

: , deliver_now . deliver_later . , SMTP . - deliver_later, .

+4
2

. , , , , Resque .

, God, . sudo service god restart reset . , sudo god stop, , ps aux | grep resque, sudo service god stop sudo service god start.

- , Sidekiq, , .

0

. :

config/deploy.rb:

set :sidekiq_queue, "mailers"

-, ActiveJob " ", sidekiq gem , .

0

Source: https://habr.com/ru/post/1611655/


All Articles