Mail::Message
Inherits Reference < Object
Constants
Constructors
Class methods
Instance methods
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 mikel@test.lindsaar.net' mail.from #=> ['mikel@test.lindsaar.net'] mail.from = 'Mikel mikel@test.lindsaar.net, ada@test.lindsaar.net' mail.from #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
Also allows you to set the value by passing a value as a parameter
Example:
mail.from 'Mikel mikel@test.lindsaar.net' mail.from #=> ['mikel@test.lindsaar.net']
Additionally, you can append new addresses to the returned Array like object.
Example:
mail.from 'Mikel mikel@test.lindsaar.net' mail.from << 'ada@test.lindsaar.net' mail.from #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
Sets the From value of the mail object, pass in a string of the field
Example:
mail.from = 'Mikel mikel@test.lindsaar.net' mail.from #=> ['mikel@test.lindsaar.net'] mail.from = 'Mikel mikel@test.lindsaar.net, ada@test.lindsaar.net' mail.from #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
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: mikel@test.lindsaar.net\r\nFrom: Bob@bob.com' mail.header #=> <#Mail::Header
Returns the MIME media type of part we are on, this is taken from the content-type header
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 mikel@test.lindsaar.net' mail.to #=> ['mikel@test.lindsaar.net'] mail.to = 'Mikel mikel@test.lindsaar.net, ada@test.lindsaar.net' mail.to #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
Also allows you to set the value by passing a value as a parameter
Example:
mail.to 'Mikel mikel@test.lindsaar.net' mail.to #=> ['mikel@test.lindsaar.net']
Additionally, you can append new addresses to the returned Array like object.
Example:
mail.to 'Mikel mikel@test.lindsaar.net' mail.to << 'ada@test.lindsaar.net' mail.to #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
Sets the To value of the mail object, pass in a string of the field
Example:
mail.to = 'Mikel mikel@test.lindsaar.net' mail.to #=> ['mikel@test.lindsaar.net'] mail.to = 'Mikel mikel@test.lindsaar.net, ada@test.lindsaar.net' mail.to #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']