Mailtrap.Email (mailtrap v0.1.2)
Contains functions for composing email
Link to this section Summary
Functions
Puts attachments struct to the email struct
Puts blind carbon copy recepient or list of blind carbon copy recepients to the email struct
Puts category to the email struct
Puts carbon copy recepient or list of carbon copy recepients to the email struct
Puts custom_variables to the email struct.
Puts from field to the email
Puts headers to the email struct.
Puts html to the email struct
Puts subject to the email struct
Puts text to the email struct
Puts recepient or list of recepients to the email struct
Link to this section Types
address()
address_list()
@type t() :: %Mailtrap.Email{ attachments: nil | [Mailtrap.Email.Attachment.t(), ...], bcc: nil | [Mailtrap.Email.Mailbox.t(), ...], category: nil | String.t(), cc: nil | [Mailtrap.Email.Mailbox.t(), ...], custom_variables: nil | map(), from: nil | Mailtrap.Email.Mailbox.t(), headers: nil | map(), html: nil | String.t(), subject: nil | String.t(), text: nil | String.t(), to: nil | [Mailtrap.Email.Mailbox.t(), ...] }
Link to this section Functions
put_attachments(email, attachments)
@spec put_attachments(t(), [Mailtrap.Email.Attachment.t(), ...]) :: t()
Puts attachments struct to the email struct
examples
Examples
iex> attachment = Mailtrap.Email.Attachment.build("content", "filename") iex> Mailtrap.Email.put_attachments(%Mailtrap.Email{}, [attachment]) %Mailtrap.Email{
attachments: [
%Mailtrap.Email.Attachment{
filename: "filename",
content: "Y29udGVudA=="
}
]
}
put_bcc(email, list)
@spec put_bcc( t(), {String.t() | nil, String.t()} ) :: t()
@spec put_bcc(t(), [tuple(), ...]) :: t()
Puts blind carbon copy recepient or list of blind carbon copy recepients to the email struct
examples
Examples
iex> Mailtrap.Email.put_bcc(%Mailtrap.Email{}, {"Jane", "jane.doe@example.org"}) %Mailtrap.Email{bcc: [%Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}]}
iex> Mailtrap.Email.put_bcc(%Mailtrap.Email{}, [{"Jane", "jane.doe@example.org"}, {"John", "john.doe@example.org"}]) %Mailtrap.Email{bcc: [%Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}, %Mailtrap.Email.Mailbox{name: "John", email: "john.doe@example.org"}]}
put_category(email, category)
Puts category to the email struct
examples
Examples
iex> Mailtrap.Email.put_category(%Mailtrap.Email{}, "Marketing") %Mailtrap.Email{category: "Marketing"}
put_cc(email, list)
Puts carbon copy recepient or list of carbon copy recepients to the email struct
examples
Examples
iex> Mailtrap.Email.put_cc(%Mailtrap.Email{}, {"Jane", "jane.doe@example.org"}) %Mailtrap.Email{cc: [%Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}]}
iex> Mailtrap.Email.put_cc(%Mailtrap.Email{}, [{"Jane", "jane.doe@example.org"}, {"John", "john.doe@example.org"}]) %Mailtrap.Email{cc: [%Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}, %Mailtrap.Email.Mailbox{name: "John", email: "john.doe@example.org"}]}
put_custom_variables(email, custom_variables)
Puts custom_variables to the email struct.
Values that are specific to the entire send that will be carried along with the email and its activity data. Total size of custom variables in JSON form must not exceed 1000 bytes.
examples
Examples
iex> Mailtrap.Email.put_custom_variables(%Mailtrap.Email{}, %{foo: "bar"}) %Mailtrap.Email{custom_variables: %{foo: "bar"}}
put_from(email, address)
Puts from field to the email
examples
Examples
iex> Mailtrap.Email.put_from(%Mailtrap.Email{}, {"Jane", "jane.doe@example.org"}) %Mailtrap.Email{from: %Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}}
put_headers(email, headers)
Puts headers to the email struct.
An object containing key/value pairs of header names and the value to substitute for them. The key/value pairs must be strings. You must ensure these are properly encoded if they contain unicode characters. These headers cannot be one of the reserved headers.
examples
Examples
iex> Mailtrap.Email.put_headers(%Mailtrap.Email{}, %{"X-Custom-Header" => "header-value"}) %Mailtrap.Email{headers: %{"X-Custom-Header" => "header-value"}}
put_html(email, html)
Puts html to the email struct
examples
Examples
iex> Mailtrap.Email.put_html(%Mailtrap.Email{}, "<strong>Hello, Jane</strong>") %Mailtrap.Email{html: "<strong>Hello, Jane</strong>"}
put_subject(email, subject)
Puts subject to the email struct
examples
Examples
iex> Mailtrap.Email.put_subject(%Mailtrap.Email{}, "Hello") %Mailtrap.Email{subject: "Hello"}
put_text(email, text)
Puts text to the email struct
examples
Examples
iex> Mailtrap.Email.put_text(%Mailtrap.Email{}, "Hello, Jane") %Mailtrap.Email{text: "Hello, Jane"}
put_to(email, list)
Puts recepient or list of recepients to the email struct
examples
Examples
iex> Mailtrap.Email.put_to(%Mailtrap.Email{}, {"Jane", "jane.doe@example.org"}) %Mailtrap.Email{to: [%Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}]}
iex> Mailtrap.Email.put_to(%Mailtrap.Email{}, [{"Jane", "jane.doe@example.org"}, {"John", "john.doe@example.org"}]) %Mailtrap.Email{to: [%Mailtrap.Email.Mailbox{name: "Jane", email: "jane.doe@example.org"}, %Mailtrap.Email.Mailbox{name: "John", email: "john.doe@example.org"}]}