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]}
Functions
Specs
add_cc(SendGrid.Email.t, String.t) :: SendGrid.Email.t
add_cc(SendGrid.Email.t, [String.t]) :: SendGrid.Email.t
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")
Specs
add_substitution(SendGrid.Email.t, String.t, String.t) :: SendGrid.Email.t
Adds a subtitution value to be used with a template. This function replaces existing key values.
Email.add_substitution(%Email{}, "-sentIn-", "Elixir")
Specs
build :: SendGrid.Email.t
Builds an an empty email to compose on.
Email.build()
%Email{}
Specs
delete_cc(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Deletes a single CC
address from the email.
Email.delete_cc(%Email{cc:["test@email.com"]}, "test@email.com"))
%Email{cc:[]}
Specs
put_from(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the from
field for the email.
Email.put_from(%Email{}, "test@email.com")
Specs
put_from_name(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the from_name
field for the email.
Email.put_from_name(%Email{}, "John Doe")
Specs
put_html(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the html
content of the email.
Email.put_html("<html><body><p>Sent from Elixir!</p></body></html>")
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")
Specs
put_subject(SendGrid.Email.t, String.t) :: SendGrid.Email.t
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")
Specs
put_template(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Uses a predefined template for the email.
Email.put_template(%Email{}, "the_template_id")
Specs
put_text(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets text
content of the email.
Email.put_text(%Email{}, "Sent from Elixir!")
Specs
put_to(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the to
field for the email.
Email.put_to(%Email{}, "test@email.com")