title: Why is email not being sent with ActiveJob?
body: <p>I'm in the process of upgrading an app to Rails 4.2 so we can take advantage of the ActionMailer's <code>deliver_later</code> method. Everything is working great in development. When I deploy to our staging server using the <code>capistrano-sidekiq</code> gem, emails don't appear to be delivered. Based on this log, it appears the job is queued and executed properly.</p>
  
  <p>Server is Ubuntu 14.04 with redis installed via apt-get.</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>I checked to see if sidekiq was running using <code>ps aux | [sS]idekiq</code> and there is an entry:</p>
  
  <pre><code>deploy   15104  0.4  7.4 972692 152452 ?       Sl   10:07   0:03 sidekiq 3.5.1 sustainabilityassessment_staging [0 of 25 busy]
  </code></pre>
  
  <p>I also ensured the mailers queue exists with <code>set :sidekiq_queue, ["default", "mailers"]</code> in my <code>deploy.rb</code>.</p>
  
  <p>My mailer method:</p>
  
  <pre><code>def admin_message(subject, message)
      @message = message
      mail(to: "&lt;address&gt;", subject: subject)
    end
  </code></pre>
  
  <p>Any idea what's going on or what I can troubleshoot next?</p>
  
  <p>Edit:
  Did some more digging. I started sidekiq using <code>RAILS_ENV=staging bundle exec sidekiq -q mailers -q default</code> in the <code>appname/current</code> and tried sending the emails again. This time the emails sent, so there appears to be something wrong with the way the capistrano-sidekiq gem starts sidekiq.</p>
  
  <p>Edit:
  Setup sidekiq's monitoring application to see if I could learn anything new. It appears jobs are being processed without issue. Still am not receiving email...</p>
  
  <p>Edit: Discovered an extra <code>config.action_mailer.raise_delivery_errors = false</code> in <code>config/environments/staging.rb</code> that was blocking me from seeing my errors. I can now see emails are being rejected:</p>
  
  <pre><code>Net::SMTPServerBusy: 454 4.7.1 &lt;email address&gt;: Relay access denied
  </code></pre>
  
  <p>Edit: One more piece of information, calling <code>deliver_now</code> on the same mailer works. Calling <code>deliver_later</code> causes the emails to be rejected. This leads me to think the SMTP settings for the app are working. Something is happening in the <code>deliver_later</code> call to prevent the email from being sent.</p>