diff --git a/app/mailers/invoice_mailer.rb b/app/mailers/invoice_mailer.rb index 54c6a8605..c3eb20f6f 100644 --- a/app/mailers/invoice_mailer.rb +++ b/app/mailers/invoice_mailer.rb @@ -1,8 +1,9 @@ class InvoiceMailer < ApplicationMailer include Que::Mailer - def invoice_email(invoice_id, html) + def invoice_email(invoice_id, html, billing_email) @invoice = Invoice.find_by(id: invoice_id) + billing_email ||= @invoice.billing_email return unless @invoice return if whitelist_blocked?(@invoice.billing_email) @@ -11,6 +12,6 @@ class InvoiceMailer < ApplicationMailer invoice = @invoice attachments[invoice.pdf_name] = pdf - mail(to: format(invoice.billing_email), subject: invoice) + mail(to: format(billing_email), subject: invoice) end end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 0c4e23a08..8bc5137d5 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -117,7 +117,7 @@ class Invoice < ActiveRecord::Base return false unless valid? return false unless billing_email.present? - InvoiceMailer.invoice_email(id, html).deliver + InvoiceMailer.invoice_email(id, html, billing_email).deliver true end