class

Athena::MIME::Email

Inherits Athena::MIME::Message < Reference < Object

Provides a high-level API for creating an email.

email = AMIME::Email
  .new
  .from("me@example.com")
  .to("you@example.com")
  .cc("them@example.com")
  .bcc("other@example.com")
  .reply_to("me@example.com")
  .priority(:high)
  .subject("Important Notification")
  .text("Lorem ipsum...")
  .html("<h1>Lorem ipsum</h1> <p>...</p>")
  .attach_from_path("/path/to/file.pdf", "my-attachment.pdf")
  .embed_from_path("/path/to/logo.png")

# ...

Instance methods

add_bcc(*addresses : AMIME::Address | String) : self

Appends the provided addresses to the list of current bcc addresses.

Source
add_cc(*addresses : AMIME::Address | String) : self

Appends the provided addresses to the list of current cc addresses.

Source
add_from(*addresses : AMIME::Address | String) : self

Appends the provided addresses to the list of current from addresses.

Source
add_part(part : AMIME::Part::Data) : self

Adds the provided part as an email attachment. Consider using #attach or #embed or one of their variants to provide a simpler API.

Source
add_reply_to(*addresses : AMIME::Address | String) : self

Appends the provided addresses to the list of current reply-to addresses.

Source
add_to(*addresses : AMIME::Address | String) : self

Appends the provided addresses to the list of current to addresses.

Source
attach(body : String | IO, name : String | Nil = nil, content_type : String | Nil = nil) : self

Adds an attachment with the provided body, optionally with the provided name and content_type.

Source
attach_from_path(path : String | Path, name : String | Nil = nil, content_type : String | Nil = nil) : self

Attaches the file at the provided path as an attachment, optionally with the provided name and content_type.

Source
attachments

Returns an array of AMIME::Part::Data representing the email's attachments.

Source
bcc

Returns the bcc addresses of this email, or an empty array if none were set.

Source
bcc(*addresses : AMIME::Address | String) : self

Sets the cc addresses of this email to the provided addresses, overriding any previously added ones.

Source
body

Returns the MIME representation of this email.

Source
cc

Returns the cc addresses of this email, or an empty array if none were set.

Source
cc(*addresses : AMIME::Address | String) : self

Sets the cc addresses of this email to the provided addresses, overriding any previously added ones.

Source
date(date : Time) : self

Sets the date of this email to the provided date.

Source
date

Returns the date of this email, or nil if none is set.

Source
embed(body : String | IO, name : String | Nil = nil, content_type : String | Nil = nil) : self

Adds an embedded attachment with the provided body, optionally with the provided name and content_type.

Source
embed_from_path(path : String | Path, name : String | Nil = nil, content_type : String | Nil = nil) : self

Embeds the file at the provided path as an attachment, optionally with the provided name and content_type.

Source
ensure_validity!

Asserts that this message is in a valid state to be sent, raising an AMIME::Exception::Logic error if not.

Source
from

Returns the from addresses of this email, or an empty array if none were set.

Source
from(*addresses : AMIME::Address | String) : self

Sets the from addresses of this email to the provided addresses, overriding any previously added ones.

Source
html(body : String | IO | Nil, charset : String = "UTF-8") : self

Sets the HTML content of this email to the provided body, optionally with the provided charset.

Source
html_body

Returns the HTML content of this email.

Source
html_charset

Returns the charset of the #html_body for this email.

Source
priority(priority : AMIME::Email::Priority) : self

Sets the priority of this email to the provided priority.

Source
priority

Returns the priority of this email.

Source
reply_to

Returns the reply-to addresses of this email, or an empty array if none were set.

Source
reply_to(*addresses : AMIME::Address | String) : self

Sets the reply-to addresses of this email to the provided addresses, overriding any previously added ones.

Source
return_path(address : AMIME::Address | String) : self

Sets the return path of this email to the provided address.

Source
return_path

Returns the return path of this email, or nil if none is set.

Source
sender(address : AMIME::Address | String) : self

Sets the sender of this email to the provided address.

Source
sender

Returns the sender of this email, or nil if none is set.

Source
subject(subject : String) : self

Sets the subject of this email to the provided subject.

Source
subject

Returns the subject of this email, or nil if none is set.

Source
text(body : String | IO | Nil, charset : String = "UTF-8") : self

Sets the textual content of this email to the provided body, optionally with the provided charset.

Source
text_body

Returns the textual content of this email.

Source
text_charset

Returns the charset of the #text_body for this email.

Source
to

Returns the to addresses of this email, or an empty array if none were set.

Source
to(*addresses : AMIME::Address | String) : self

Sets the to addresses of this email to the provided addresses, overriding any previously added ones.

Source

Nested types