class Marten::Emailing::Email

Overview

Abstract base email class.

This class holds the definition of a single email. It is supposed to be subclassed and each subclass is responsible for defining how it should be initialized, the email properties, and how it should be rendered (for example, using a specific HTML template).

Included Modules

Defined in:

marten/emailing/email.cr
marten/emailing/email/callbacks.cr
marten/template/ext/emailing/email.cr

Class Method Summary

Instance Method Summary

Macro Summary

Class Method Detail

def self.backend(backend : Backend::Base) : Nil #

Allows to set the specific backend to use for this email.


[View source]
def self.backend : Backend::Base | Nil #

Returns the specific backend to use for this email.

A nil value indicate that the default backend will be used.


[View source]
def self.html_template_name : String | Nil #

Returns the configured HTML body template name.


[View source]
def self.template_name(template_name : String | Nil, content_type : ContentType | String | Symbol = ContentType::HTML) : Nil #

Allows to configure the template that should be rendered when generating the body of the email.


[View source]
def self.text_template_name : String | Nil #

Returns the configured text body template name.


[View source]

Instance Method Detail

def backend #

Returns the emailing backend to use in order to send this email.


[View source]
def bcc : Array(Address) | Nil #

Returns the email addresses the email should be BBC'ed to.


[View source]
def cc : Array(Address) | Nil #

Returns the email addresses the email should be CC'ed to.


[View source]
def context #

Returns the global template context.

This context object can be mutated for the lifetime of the email in order to define which variables will be made available to the template runtime when rendering the email body.


[View source]
def deliver #

Delivers the email.


[View source]
def from : Address #

Returns the sender email address.


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

Returns the headers to set on the email.


[View source]
def html_body : String | Nil #

Returns the HTML body.


[View source]
def html_template_name : String | Nil #

Returns the template name that should be used to render the HTML body.


[View source]
def reply_to : Address | Nil #

Returns the reply-to email address.


[View source]
def subject : String | Nil #

Returns the subject of the email.


[View source]
def text_body : String | Nil #

Returns the text body.


[View source]
def text_template_name : String | Nil #

Returns the template name that should be used to render the text body.


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

Returns an array of recipient email addresses.


[View source]

Macro Detail

macro bcc(value) #

Allows to define the email addresses the email should be BBC'ed to.


[View source]
macro cc(value) #

Allows to define the email addresses the email should be BC'ed to.


[View source]
macro from(value) #

Allows to define the sender email address.


[View source]
macro reply_to(value) #

Allows to define the reply-to email address.


[View source]
macro subject(value) #

Allows to define the subject of the email.


[View source]
macro to(value) #

Allows to define the email addresses of the recipients of the email.


[View source]