[Ruby] ar_mailer including bcc headers
Victor Cosby
victorcosby at gmail.com
Sun Jul 29 14:04:08 PDT 2007
I've been seeing Bcc headers in the messages I'm sending with
ar_mailer. This never happened in action_mailer so I'm trying to
determine why this might be different.
The Bcc header is not sent in the deliveries sent via action_mailer,
and I believe I see a test for this in mail_service_test.rb (1.1.3):
def test_headers_removed_on_smtp_delivery
ActionMailer::Base.delivery_method = :smtp
TestMailer.deliver_cc_bcc(@recipient)
assert MockSMTP.deliveries[0][2].include?("root at loudthinking.com")
assert MockSMTP.deliveries[0][2].include?("nobody at loudthinking.com")
assert MockSMTP.deliveries[0][2].include?(@recipient)
assert_match %r{^Cc: nobody at loudthinking.com}, MockSMTP.deliveries[0][0]
assert_match %r{^To: #{@recipient}}, MockSMTP.deliveries[0][0]
assert_no_match %r{^Bcc: root at loudthinking.com}, MockSMTP.deliveries[0][0]
end
Since ARMailer creates a separate email message for each destination,
should it remove the Bcc header?
For example, this monkey patch is working for me, but I sense I might
be missing something.
def perform_delivery_activerecord(mail)
# Remove Bcc header when creating the mail so recipients never see it
mail.destinations.each do |destination|
@@email_class.create :mail => mail.encoded.sub(/^Bcc:.*\n/, ''),
:to => destination,
:from => mail.from.first
end
end
Thanks,
Victor
More information about the Ruby
mailing list