【问题标题】:ActionMailer + Sidekiq/Redis Sending Duplicate Emails Repeatedly - Rails 4ActionMailer + Sidekiq/Redis 重复发送重复的电子邮件 - Rails 4
【发布时间】:2020-05-22 01:31:33
【问题描述】:

我在本地 ubuntu 18 机器上的开发环境中运行 rails 和 redis。

ActionMailer 正在适当地发送电子邮件,但似乎我的计算机已关闭,第二天我来启动 redis,它重新发送了一堆电子邮件。

#invoice controller
InvoiceMailer.send_invoice_to_email(email, @invoice).deliver_later

#InvoiceMailer
    def send_invoice_to_email(email, invoice)
        @invoice = invoice
        attachments["test_invoice_#{invoice.id}_#{Date.today}.pdf"] = WickedPdf.new.pdf_from_string(
            render_to_string(pdf: 'Invoice', template: '/invoices/show.pdf.erb', layout: 'application')
        )

        bcc = ["test <test@test.com>", "test2 <test2@test.com>"]
        mail(from: "Test <info@test.com>", to: email, bcc: bcc, subject: "Invoice From test")
    end

我的问题可能是什么?我该如何调试?

【问题讨论】:

    标签: ruby-on-rails-4 redis actionmailer sidekiq


    【解决方案1】:

    供将来参考 - 我相信没有重复的电子邮件被发送出去。我的逻辑有些问题。如果您遇到这种情况,请首先确保 sidekiq 不会排队稍后同时发送的电子邮件。此外,如果您通过发送实际电子邮件来测试它会变得混乱 - 请注意如何添加“to”、“cc”、“bcc”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-31
      • 2013-11-13
      • 2020-04-24
      • 2011-08-11
      • 1970-01-01
      • 1970-01-01
      • 2016-11-03
      • 2023-03-25
      相关资源
      最近更新 更多