ActionMailer + Sidekiq / Redis重复发送重复的电子邮件-Rails 4

问题描述 投票:0回答:1

我正在本地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 <[email protected]>", "test2 <[email protected]>"]
        mail(from: "Test <[email protected]>", to: email, bcc: bcc, subject: "Invoice From test")
    end

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

ruby-on-rails-4 redis actionmailer sidekiq
1个回答
0
投票

供以后参考-我相信不会发送重复的电子邮件。我的逻辑有些问题。如果您遇到这种情况,请首先确保sidekiq不在排队的电子邮件中,然后稍后再发送出去。另外,如果您通过发送实际的电子邮件进行测试,也会引起混淆-请注意如何添加“至”,“ cc”,“密件抄送”。

© www.soinside.com 2019 - 2024. All rights reserved.