Class | TMail::HeaderField
In: | lib/action_mailer/vendor/tmail-1.2.3/tmail/header.rb
Parent: | Object

Provides methods to handle and manipulate headers in the email

### Methods

accept body body= empty? illegal? inspect internal_new new new new_from_port

### Included Modules

TextUtils StrategyInterface

### Constants

FNAME_TO_CLASS | = | { 'date' => DateTimeHeader, 'resent-date' => DateTimeHeader, 'to' => AddressHeader, 'cc' => AddressHeader, 'bcc' => AddressHeader, 'from' => AddressHeader, 'reply-to' => AddressHeader, 'resent-to' => AddressHeader, 'resent-cc' => AddressHeader, 'resent-bcc' => AddressHeader, 'resent-from' => AddressHeader, 'resent-reply-to' => AddressHeader, 'sender' => SingleAddressHeader, 'resent-sender' => SingleAddressHeader, 'return-path' => ReturnPathHeader, 'message-id' => MessageIdHeader, 'resent-message-id' => MessageIdHeader, 'in-reply-to' => ReferencesHeader, 'received' => ReceivedHeader, 'references' => ReferencesHeader, 'keywords' => KeywordsHeader, 'encrypted' => EncryptedHeader, 'mime-version' => MimeVersionHeader, 'content-type' => ContentTypeHeader, 'content-transfer-encoding' => ContentTransferEncodingHeader, 'content-disposition' => ContentDispositionHeader, 'content-id' => MessageIdHeader, 'subject' => UnstructuredHeader, 'comments' => UnstructuredHeader, 'content-description' => UnstructuredHeader

### External Aliases

new | -> | newobj

### Public Class methods

internal_new( name, conf )
new( body, conf, intern = false )
new( name, body, conf = DEFAULT_CONFIG )
new_from_port( port, name, conf = DEFAULT_CONFIG )

Returns a HeaderField object matching the header you specify in the "name" param. Requires an initialized TMail::Port to be passed in.

The method searches the header of the Port you pass into it to find a match on the header line you pass. Once a match is found, it will unwrap the matching line as needed to return an initialized HeaderField object.

If you want to get the Envelope sender of the email object, pass in "EnvelopeSender", if you want the From address of the email itself, pass in ‘From’.

This is because a mailbox doesn‘t have the : after the From that designates the beginning of the envelope sender (which can be different to the from address of the emial)

Other fields can be passed as normal, "Reply-To", "Received" etc.

Note: Change of behaviour in 1.2.1 => returns nil if it does not find the specified header field, otherwise returns an instantiated object of the correct header class

For example:

      port = TMail::FilePort.new("/test/fixtures/raw_email_simple")
      h = TMail::HeaderField.new_from_port(port, "From")
      h.addrs.to_s #=> "Mikel Lindsaar <mikel@nowhere.com>"
      h = TMail::HeaderField.new_from_port(port, "EvelopeSender")
      h.addrs.to_s #=> "mike@anotherplace.com.au"
      h = TMail::HeaderField.new_from_port(port, "SomeWeirdHeaderField")
      h #=> nil

### Public Instance methods

accept( strategy )
body()
body=( str )
empty?()
illegal?()
inspect()

[Validate]