struct Amber::Mailer::Email

Overview

Represents a fully constructed email message ready for delivery.

An Email contains all the headers, body content, and attachments needed to generate a complete MIME message. Emails are typically built by the Base mailer class and passed to a DeliveryAdapter for sending.

Example

email = Email.new(
  to: ["[email protected]"],
  from: "[email protected]",
  subject: "Hello",
  html_body: "<h1>Hello!</h1>",
  text_body: "Hello!"
)

mime_message = email.to_mime

Defined in:

amber/mailer/email.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(to : Array(String) = [] of String, from : String = "", subject : String = "", cc : Array(String) = [] of String, bcc : Array(String) = [] of String, reply_to : String | Nil = nil, html_body : String | Nil = nil, text_body : String | Nil = nil, headers : Hash(String, String) = {} of String => String, attachments : Array(Attachment) = [] of Attachment) #

[View source]

Instance Method Detail

def all_recipients : Array(String) #

Returns all recipient addresses (to + cc + bcc) for SMTP envelope delivery.


[View source]
def attachments : Array(Attachment) #

[View source]
def attachments=(attachments : Array(Attachment)) #

[View source]
def bcc : Array(String) #

[View source]
def bcc=(bcc : Array(String)) #

[View source]
def cc : Array(String) #

[View source]
def cc=(cc : Array(String)) #

[View source]
def from : String #

[View source]
def from=(from : String) #

[View source]
def headers : Hash(String, String) #

[View source]
def headers=(headers : Hash(String, String)) #

[View source]
def html_body : String | Nil #

[View source]
def html_body=(html_body : String | Nil) #

[View source]
def reply_to : String | Nil #

[View source]
def reply_to=(reply_to : String | Nil) #

[View source]
def subject : String #

[View source]
def subject=(subject : String) #

[View source]
def text_body : String | Nil #

[View source]
def text_body=(text_body : String | Nil) #

[View source]
def to : Array(String) #

[View source]
def to=(to : Array(String)) #

[View source]
def to_mime : String #

Generates a complete MIME-formatted email message string.

The MIME structure depends on the content present:

  • Text only: single-part text/plain
  • HTML only: single-part text/html
  • Text + HTML: multipart/alternative
  • With attachments: multipart/mixed wrapping the body parts

[View source]