class Mail::Message
 
  - Mail::Message
- Reference
- Object
Direct Known Subclasses
Defined in:
mail/message.crConstant Summary
- 
        HEADER_SEPARATOR = /#{Constants::LAX_CRLF}#{Constants::LAX_CRLF}/
Constructors
Class Method Summary
Instance Method Summary
- 
        #add_part(part)
        
          Adds a part to the parts list or creates the part list 
- #all_parts
- 
        #body(value = nil)
        
          Returns the body of the message object. 
- 
        #body=(value)
        
          Sets the body object of the message object. 
- 
        #body_lazy(value)
        
          see comments to body=. 
- 
        #boundary
        
          Returns the current boundary for this message part 
- 
        #charset
        
          Returns the character set defined in the content type field 
- 
        #charset=(value : String)
        
          Sets the charset to the supplied value. 
- #content_transfer_encoding(val = nil)
- #content_transfer_encoding=(val)
- #content_type(val = nil)
- #content_type=(val)
- 
        #content_type_parameters
        
          Returns the content type parameters 
- 
        #default(str, val = nil)
        
          Returns the default value of the field requested as a symbol. 
- #envelope_date
- #envelope_from
- #find_first_mime_type(ct)
- 
        #from(val = nil)
        
          Returns the From value of the mail object as an array of strings of address specs. 
- 
        #from=(val)
        
          Sets the From value of the mail object, pass in a string of the field 
- #has_content_transfer_encoding?
- #has_content_type?
- 
        #header(value = nil)
        
          Returns the header object of the message object. 
- 
        #header=(value)
        
          Sets the header of the message object. 
- 
        #html_part
        
          Accessor for html_part 
- #html_part(&block)
- 
        #main_type
        
          Returns the main content type 
- 
        #mime_type
        
          Returns the MIME media type of part we are on, this is taken from the content-type header 
- 
        #multipart?
        
          Returns true if the message is multipart 
- 
        #parts
        
          Returns a parts list object of all the parts in the message 
- 
        #raw_envelope : String?
        
          Type field that you can see at the top of any email that has come from a mailbox 
- #raw_source : String
- #raw_source=(raw_source : String)
- #set_envelope(raw_envelope : String)
- 
        #text_part
        
          Accessor for text_part 
- #text_part(&block)
- 
        #text_part=(msg)
        
          Helper to add a text part to a multipart/alternative email. 
- 
        #to(val = nil)
        
          Returns the To value of the mail object as an array of strings of address specs. 
- 
        #to=(val)
        
          Sets the To value of the mail object, pass in a string of the field 
Constructor Detail
Class Method Detail
Instance Method Detail
Returns the body of the message object. Or, if passed a parameter sets the value.
Example:
mail = Mail::Message.new('To: mikel\r\n\r\nThis is the body') mail.body #=> #<Mail::Body:0x13919c @raw_source="This is the bo...
mail.body 'This is another body' mail.body #=> #<Mail::Body:0x13919c @raw_source="This is anothe...
Sets the body object of the message object.
Example:
mail.body = 'This is the body' mail.body #=> #<Mail::Body:0x13919c @raw_source="This is the bo...
You can also reset the body of an Message object by setting body to nil
Example:
mail.body = 'this is the body' mail.body.encoded #=> 'this is the body' mail.body = nil mail.body.encoded #=> ''
If you try and set the body of an email that is a multipart email, then instead of deleting all the parts of your email, mail will add a text/plain part to your email:
mail.add_file 'somefilename.png' mail.parts.length #=> 1 mail.body = "This is a body" mail.parts.length #=> 2 mail.parts.last.content_type.content_type #=> 'This is a body'
Returns the default value of the field requested as a symbol.
Each header field has a :default method which returns the most common use case for that field, for example, the date field types will return a DateTime object when sent :default, the subject, or unstructured fields will return a decoded string of their value, the address field types will return a single addr_spec or an array of addr_specs if there is more than one.
Returns the From value of the mail object as an array of strings of address specs.
Example:
mail.from = 'Mikel [email protected]' mail.from #=> ['[email protected]'] mail.from = 'Mikel [email protected], [email protected]' mail.from #=> ['[email protected]', '[email protected]']
Also allows you to set the value by passing a value as a parameter
Example:
mail.from 'Mikel [email protected]' mail.from #=> ['[email protected]']
Additionally, you can append new addresses to the returned Array like object.
Example:
mail.from 'Mikel [email protected]' mail.from << '[email protected]' mail.from #=> ['[email protected]', '[email protected]']
Sets the From value of the mail object, pass in a string of the field
Example:
mail.from = 'Mikel [email protected]' mail.from #=> ['[email protected]'] mail.from = 'Mikel [email protected], [email protected]' mail.from #=> ['[email protected]', '[email protected]']
Returns the header object of the message object. Or, if passed a parameter sets the value.
Example:
mail = Mail::Message.new('To: mikel\r\nFrom: you') mail.header #=> #<Mail::Header:0x13ce14 @raw_source="To: mikel\r\nFr...
mail.header #=> nil mail.header 'To: mikel\r\nFrom: you' mail.header #=> #<Mail::Header:0x13ce14 @raw_source="To: mikel\r\nFr...
Sets the header of the message object.
Example:
mail.header = 'To: [email protected]\r\nFrom: [email protected]' mail.header #=> <#Mail::Header
Returns the MIME media type of part we are on, this is taken from the content-type header
Type field that you can see at the top of any email that has come from a mailbox
Helper to add a text part to a multipart/alternative email. If this and html_part are both defined in a message, then it will be a multipart/alternative message and set itself that way.
Returns the To value of the mail object as an array of strings of address specs.
Example:
mail.to = 'Mikel [email protected]' mail.to #=> ['[email protected]'] mail.to = 'Mikel [email protected], [email protected]' mail.to #=> ['[email protected]', '[email protected]']
Also allows you to set the value by passing a value as a parameter
Example:
mail.to 'Mikel [email protected]' mail.to #=> ['[email protected]']
Additionally, you can append new addresses to the returned Array like object.
Example:
mail.to 'Mikel [email protected]' mail.to << '[email protected]' mail.to #=> ['[email protected]', '[email protected]']
Sets the To value of the mail object, pass in a string of the field
Example:
mail.to = 'Mikel [email protected]' mail.to #=> ['[email protected]'] mail.to = 'Mikel [email protected], [email protected]' mail.to #=> ['[email protected]', '[email protected]']