Class: Mail::BccField

Inherits:
CommonAddressField show all
Defined in:
lib/mail/fields/bcc_field.rb

Overview

Blind Carbon Copy Field

The Bcc field inherits from StructuredField and handles the Bcc: header field in the email.

Sending bcc to a mail message will instantiate a Mail::Field object that has a BccField as its field type. This includes all Mail::CommonAddress module instance metods.

Only one Bcc field can appear in a header, though it can have multiple addresses and groups of addresses.

Examples:

mail = Mail.new
mail.bcc = 'Mikel Lindsaar <[email protected]>, [email protected]'
mail.bcc    #=> ['[email protected]', '[email protected]']
mail[:bcc]  #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4
mail['bcc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4
mail['Bcc'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::BccField:0x180e1c4

mail[:bcc].encoded   #=> ''      # Bcc field does not get output into an email
mail[:bcc].decoded   #=> 'Mikel Lindsaar <[email protected]>, [email protected]'
mail[:bcc].addresses #=> ['[email protected]', '[email protected]']
mail[:bcc].formatted #=> ['Mikel Lindsaar <[email protected]>', '[email protected]']

Constant Summary collapse

NAME =

:nodoc:

'Bcc'

Instance Attribute Summary collapse

Attributes inherited from CommonField

#charset, #errors, #name, #value

Instance Method Summary collapse

Methods inherited from CommonAddressField

#<<, #address, #addresses, #addrs, #decoded_group_addresses, #default, #display_names, #each, #element, #encode_if_needed, #encoded_group_addresses, #formatted, #group_addresses, #group_names, #groups, singular?

Methods inherited from CommonField

#decoded, #default, #element, #parse, parse, #responsible_for?, singular?, #singular?, #to_s

Constructor Details

#initialize(value = nil, charset = nil) ⇒ BccField

Returns a new instance of BccField.



35
36
37
38
# File 'lib/mail/fields/bcc_field.rb', line 35

def initialize(value = nil, charset = nil)
  super
  self.include_in_headers = false
end

Instance Attribute Details

#include_in_headersObject

Returns the value of attribute include_in_headers.



33
34
35
# File 'lib/mail/fields/bcc_field.rb', line 33

def include_in_headers
  @include_in_headers
end

Instance Method Details

#encodedObject

Bcc field should not be :encoded by default



41
42
43
44
45
46
47
# File 'lib/mail/fields/bcc_field.rb', line 41

def encoded
  if include_in_headers
    super
  else
    ''
  end
end