You can clone with
HTTPS or Subversion.
1.9.3p194 :008 > mail = Mail.new do
1.9.3p194 :009 > from 'email@example.com'
1.9.3p194 :010?> to 'firstname.lastname@example.org'
1.9.3p194 :011?> bcc 'email@example.com'
1.9.3p194 :012?> end
=> #, , >
1.9.3p194 :013 > mail.to_s
=> "Date: Mon, 13 Aug 2012 14:55:34 -0700\r\nFrom: firstname.lastname@example.org\r\nTo: email@example.com\r\nMessage-ID: 502977d6ab02d_17c6c3ff4cd434cdc4346a@Simon-Lees-iMac.local.mail\r\nMime-Version: 1.0\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: 7bit\r\n\r\n"
1.9.3p194 :014 >
I compared bcc_field.rb to cc_field.rb and noticed some differences in the initialize constuctor and encoded method. Here's what I updated to and it works now:
class BccField < StructuredField
FIELD_NAME = 'bcc'
CAPITALIZED_FIELD = 'Bcc'
def initialize(value = nil, charset = 'utf-8')
@charset = charset
super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
# Bcc field should never be :encoded
Hi oprogfrogo. I think that is intended behavior, as the comment suggests. The BCC field shouldn't be included in the to_s output because that's what all recipients see. If BCC were a header like any other then it wouldn't be "blind" any more.
The way BCC works in practice is that all recipients are passed to the SMTP server (To, CC, and BCC). All recipients receive the same RFC822, which only lists the To and CC recipients.
One twist is that some RFC822 emails you download will have the field. For example, GMail's IMAP server includes the BCC header for messages you've sent, but not messages you've received. I suspect this gem will swallow that field, which is kind of a bummer. Perhaps a good compromise would be an argument to to_s that lets you override the default behavior and include the BCC field.
@briantobin is spot-on. BCC on outgoing messages adds SMTP recipients without adding message headers.