sendgrid v0.1.1 SendGrid.Email

Email primitive for composing emails with SendGrid’s API.

Email.build()
  |> Email.put_to("test@email.com")
  |> Email.put_from("test2@email.com")
  |> Email.put_subject("Hello from Elixir")
  |> Email.put_text("Sent with Elixir")

%Email{
  to: "test@email.com",
  from "test2@email.com",
  subject: "Hello from Elixir",
  text: "Sent with Elixir"
}

Summary

Functions

Add recipients to the CC address field

Adds a subtitution value to be used with a template. This function replaces existing key values

Builds an an empty email to compose on

Deletes a single CC address from the email

Sets the from field for the email

Sets the from_name field for the email

Sets the html content of the email

Sets the reply_to field for the email

Sets the subject field for the email

Uses a predefined template for the email

Sets text content of the email

Sets the to field for the email

Types

substitution :: %{optional(String.t) => [String.t]}
t :: %SendGrid.Email{bcc: nil | [String.t], cc: nil | [String.t], from: String.t, from_name: nil | String.t, html: nil | String.t, reply_to: nil | String.t, sub: nil | substitution, subject: nil | String.t, text: nil | String.t, to: String.t, x_smtpapi: nil | template}
template :: %{filters: %{templates: %{settings: %{enable: 1, templated_id: String.t}}}}

Functions

add_cc(email, cc_addresses)

Add recipients to the CC address field.

CC recipients can be added as a single string or a list of strings.

Email.add_cc(%Email{}, ["test1@email.com", "test2@email.com"])

Email.add_cc(%Email{}, "test@email.com")
add_substitution(email, sub_name, sub_value)

Specs

Adds a subtitution value to be used with a template. This function replaces existing key values.

Email.add_substitution(%Email{}, "-sentIn-", "Elixir")
build()

Specs

build :: SendGrid.Email.t

Builds an an empty email to compose on.

Email.build()
%Email{}
delete_cc(email, cc_address)

Deletes a single CC address from the email.

Email.delete_cc(%Email{cc:["test@email.com"]}, "test@email.com"))
%Email{cc:[]}
put_from(email, from_address)

Sets the from field for the email.

Email.put_from(%Email{}, "test@email.com")
put_from_name(email, from_name_address)

Specs

Sets the from_name field for the email.

Email.put_from_name(%Email{}, "John Doe")
put_html(email, html_body)

Sets the html content of the email.

Email.put_html("<html><body><p>Sent from Elixir!</p></body></html>")
put_reply_to(email, reply_to_address)

Specs

put_reply_to(SendGrind.Email.t, String.t) :: SendGrid.Email.t

Sets the reply_to field for the email.

Email.put_reply_to(%Email{}, "test@email.com")
put_subject(email, subject)

Specs

Sets the subject field for the email.

Setting the subject with a template changes your actual subject to be the predefined template concatenated with the subject being set.

Email.put_subject(%Email{}, "Hello from Elixir")
put_template(email, template_id)

Specs

Uses a predefined template for the email.

Email.put_template(%Email{}, "the_template_id")
put_text(email, text_body)

Sets text content of the email.

Email.put_text(%Email{}, "Sent from Elixir!")
put_to(email, to_address)

Sets the to field for the email.

Email.put_to(%Email{}, "test@email.com")