sendgrid v1.0.2 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: %{ email: "test@email.com" },
from %{ email: "test2@email.com" },
subject: "Hello from Elixir",
content: [%{ type: "text/plain", value: "Sent with Elixir" }],
...
}
Summary
Functions
Add recipients to the BCC
address field. The bcc-name can be specified as the third parameter
Add recipients to the CC
address field. The cc-name can be specified as the third parameter
Adds a subtitution value to be used with a template. This function replaces existing key values
Sets the to
field for the email. A to-name can be passed as the third parameter
Builds an an empty email to compose on
Sets the from
field for the email. The from-name can be specified as the third parameter
Sets the html
content of the email
Sets the reply_to
field for the email. The reply-to name can be specified as the third parameter
Sets a future date of when to send the email
Sets the subject
field for the email
Uses a predefined template for the email
Sets text
content of the email
Types
substitutions :: %{optional(String.t) => String.t}
Functions
Specs
add_bcc(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Add recipients to the BCC
address field. The bcc-name can be specified as the third parameter.
Email.add_bcc(%Email{}, "test@email.com")
Email.add_bcc(%Email{}, "test@email.com", "John Doe")
Specs
add_bcc(SendGrid.Email.t, String.t, String.t) :: SendGrid.Email.t
Specs
add_cc(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Add recipients to the CC
address field. The cc-name can be specified as the third parameter.
Email.add_cc(%Email{}, "test@email.com")
Email.add_cc(%Email{}, "test@email.com", "John Doe")
Specs
add_cc(SendGrid.Email.t, String.t, String.t) :: SendGrid.Email.t
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
add_to(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the to
field for the email. A to-name can be passed as the third parameter.
Email.add_to(%Email{}, "test@email.com")
Email.add_to(%Email{}, "test@email.com", "John Doe")
Specs
add_to(SendGrid.Email.t, String.t, String.t) :: SendGrid.Email.t
Specs
build :: SendGrid.Email.t
Builds an an empty email to compose on.
Email.build()
# %Email{...}
Specs
put_from(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the from
field for the email. The from-name can be specified as the third parameter.
Email.put_from(%Email{}, "test@email.com")
Email.put_from(%Email{}, "test@email.com", "John Doe")
Specs
put_from(SendGrid.Email.t, String.t, String.t) :: SendGrid.Email.t
Specs
put_html(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the html
content of the email.
Email.put_html(%Email{}, "<html><body><p>Sent from Elixir!</p></body></html>")
Specs
put_reply_to(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the reply_to
field for the email. The reply-to name can be specified as the third parameter.
Email.put_reply_to(%Email{}, "test@email.com")
Email.put_reply_to(%Email{}, "test@email.com", "John Doe")
Specs
put_reply_to(SendGrid.Email.t, String.t, String.t) :: SendGrid.Email.t
Specs
put_send_at(SendGrid.Email.t, integer) :: SendGrid.Email.t
Sets a future date of when to send the email.
Email.put_send_at(%Email{}, 1409348513)
Specs
put_subject(SendGrid.Email.t, String.t) :: SendGrid.Email.t
Sets the subject
field for the email.
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!")