3

I have a functionality wherein i have to upload a large number of records from a csv file. If any one of the records is invalid, no data should be uploaded. A csv file with errors against the invalid records needs to be sent to the user who uploaded the data. I am using rails (3.2), sidekiq (2.16.1) and mysql.

All the mails (devise and custom) mails are delivered and i receive them in my gmail inbox. The above functionality worked fine before being shifted to sidekiq.

User model

#works n gets delivered in inbox
Notifier.send_welcome_mail(self).deliver 

Sidekiq Worker

class UploadWorker
  include Sidekiq::Worker
  sidekiq_options retry: false

  def perform(user_id, inspection_id)
    user = User.find(user_id)
    inspection = Inspection.find(inspection_id)
    err = false
    #check if all data is valid and upload if valid
    #
    ...
    #shows in development log but doesnt get delivered in inbox.
    Notifier.delay.upload_success(user, inspection) if err
    Notifier.delay.upload_failed(user, inspection) unless err
  end
end

development log

Sent mail to someone@gmail.com (142ms)
Date: Wed, 13 Nov 2013 17:24:25 +0530
To: someone@gmail.com
Message-ID: <5283687179a92_203f59f273e3@gmail.mail>
Subject: ["someone@gmail.com"] Upload failed
Mime-Version: 1.0
Content-Type: text/html;
  charset=UTF-8
Content-Transfer-Encoding: 7bit

sidekiq log

2013-11-13T13:21:20Z 10064 TID-1n41gu UploadWorker JID-2d2c930601caf6a62c86e142 INFO: start
2013-11-13T13:22:13Z 10064 TID-1n41gu UploadWorker JID-2d2c930601caf6a62c86e142 INFO: done: 52.858 sec
2013-11-13T13:22:13Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-bcae8ea4974ecfe280e411bd INFO: start
2013-11-13T13:22:14Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-bcae8ea4974ecfe280e411bd INFO: done: 0.858 sec
2013-11-13T13:23:51Z 10064 TID-1n41gu UploadWorker JID-03fe3dee40f6390f5cec1d93 INFO: start
2013-11-13T13:23:54Z 10064 TID-1n41gu UploadWorker JID-03fe3dee40f6390f5cec1d93 INFO: done: 2.779 sec
2013-11-13T13:23:54Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-44f75877c5919302c9ded4fe INFO: start
2013-11-13T13:23:54Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-44f75877c5919302c9ded4fe INFO: done: 0.038 sec

The issue is, only the mails from sidekiq are shown as sent in log but arent delivered. Other mails from devise n custom mail do get delivered.

4

1 回答 1

0

您确定您的开发电子邮件设置设置正确吗?尝试设置以下内容config/development.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
  :address        => '127.0.0.1',
  :port           => '587',
}
于 2013-11-15T05:22:20.963 回答