title: Rails 4 ActionMailer - How to capture connection and SMTP errors when using deliver_later
body: <p>I am using ActionMailer deliver_later  w ActiveJobs /  Sidekiq using :</p>
  
  <pre><code>config.active_job.queue_adapter = :sidekiq
  </code></pre>
  
  <p>as I am testing in dev mode w MailCatcher, the only error I can catch is Errno::ECONNREFUSED, setting port 1026 instead of 1025</p>
  
  <p>When I test deliver_now, I get the Errno::ECONNREFUSED error raised, which is fine</p>
  
  <pre><code>begin
     MessageMailer.contact_me_email(@message).deliver_now
     rescue Errno::ECONNREFUSED, Net::SMTPAuthenticationError, Net::SMTPServerBusy, Net::SMTPSyntaxError, Net::SMTPFatalError, Net::SMTPUnknownError =&gt; e
       flash[:error] = "Problems sending mail. Please try again later"
       # delete message or resend it ?
       byebug
       @message.destroy
       format.html { render :new }
     end
  </code></pre>
  
  <p>However, when I request a deliver_later, then the request is sore in the sidekiq mailers queue, and the error is not captured...</p>
  
  <pre><code>       begin
     MessageMailer.contact_me_email(@message).deliver_later(wait: 1.minute ) # in mailers queue
     rescue Errno::ECONNREFUSED, Net::SMTPAuthenticationError, Net::SMTPServerBusy, Net::SMTPSyntaxError, Net::SMTPFatalError, Net::SMTPUnknownError =&gt; e
       flash[:error] = "Problems sending mail. Please try again later"
       # delete message or resend it ?
       byebug
       @message.destroy
       format.html { render :new }
     end
  </code></pre>
  
  <p>How can I capture and rescue from SMTP errors in this case ? I guess it's a Sidekiq responsibility to handle it ... any hint   welcome..</p>