Method: Mail::Header#[]

Defined in:
lib/mail/header.rb

#[](name) ⇒ Object

3.6. Field definitions

The following table indicates limits on the number of times each
field may occur in a message header as well as any special
limitations on the use of those fields.  An asterisk next to a value
in the minimum or maximum column indicates that a special restriction
appears in the Notes column.

<snip table from 3.6>

As per RFC, many fields can appear more than once, we will return a string of the value if there is only one header, or if there is more than one matching header, will return an array of values in order that they appear in the header ordered from top to bottom.

Example:

h = Header.new
h.fields = ['To: [email protected]', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 20']
h['To']          #=> '[email protected]'
h['X-Mail-SPAM'] #=> ['15', '20']


130
131
132
# File 'lib/mail/header.rb', line 130

def [](name)
  fields.get_field(Utilities.dasherize(name))
end