kshnurov / mandrill_dm

A basic Mandrill delivery method for Rails.
MIT License
46 stars 45 forks source link

BCC #54

Open Tensho opened 7 years ago

Tensho commented 7 years ago

I was surprised, that MandrillDm::Message doesn't have #bcc method. After digging some code I noticed, that we accumulate to, cc and bcc inside #combine_address_fields and handle BCC this way. But I can't understand, what is the difference between classic bcc field and custom Mandrillbcc_address parameter? Example:

class AlphabetMailer < ActionMailer::Base
  def a
    mail(from: 'anything@example.com',
         to: 'a.babichev@example.com',
         bcc: 'andrew.babichev@gmail.com',
         subject: 'Alpha',
         body: '',
         delivery_method: :mandrill)
  end

  def b
    mail(from: 'anything@example.com',
         to: 'a.babichev@example.com',
         bcc_address: 'andrew.babichev@gmail.com',
         subject: 'Beta',
         body: '',
         delivery_method: :mandrill)
  end
end

# AlphabetMailer.a.deliver_now and AlphabetMailer.b.deliver_now work the same as expected.
Tensho commented 7 years ago

Guys, I'm afraid my question is not relevant and I should dig somewhere else, so please can you share your thoughts?

AnkurVyas-BTC commented 7 years ago

@Tensho - I also tried to use the bcc method but it was not picking up the merge vars which I passed in the with the rcpt parameter.

bcc_address: an optional address to receive an exact copy of each recipient's email (Ref: https://mandrillapp.com/api/docs/messages.html )

I was saved by bcc address parameter. It sends the exact copy of the recipient's email. If you want to send bcc email with this gem please use the bcc_address parameter.

Tensho commented 7 years ago

I guess to be consolidated with ActioMailer API mandrill_dm should expose #bcc method and use #bcc_address method/parameter under the hood. This allows just to switch delivery method in ActionMailer::Base#mail call without the need to have the conditional clause for BCC option. Does it make sense?