sidekiq没有发送邮件

时间:2013-11-13 12:53:09

标签: ruby-on-rails-3 actionmailer sidekiq

我有一个功能,我必须从csv文件上传大量记录。如果任何一条记录无效,则不应上传任何数据。需要将具有针对无效记录的错误的csv文件发送给上载数据的用户。我使用rails(3.2),sidekiq(2.16.1)和mysql。

所有邮件(设计和自定义)邮件都已发送,我在我的Gmail收件箱中收到邮件。在转移到sidekiq之前,上述功能正常工作。

用户模型

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

Sidekiq工人

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

开发日志

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

问题是,只有来自sidekiq的邮件显示为在日志中发送但未送达。来自设计邮件的其他邮件确实可以送达。

1 个答案:

答案 0 :(得分: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',
}