sendgrid v2.0.0 SendGrid.Mail View Source

Module for sending transactional email.

Sandbox Mode

Sandbox mode allows you to test sending emails without actually delivering emails and using your email quota.

To send emails in sandbox mode, ensure the config key is set:

config :sendgrid,
  api_key: "SENDGRID_API_KEY",
  sandbox_enable: true

Optionally, you can use SendGrid.Email.set_sandbox/2 to configure it per email.

Link to this section Summary


Sends the built email

Link to this section Functions

Link to this function send(email, opts \\ []) View Source
send(SendGrid.Email.t(), [SendGrid.api_key()]) ::
  :ok | {:error, [String.t()]} | {:error, String.t()}

Sends the built email.


  • :api_key - API key to use with the request.


email =
  |> Email.add_to("")
  |> Email.put_from("")
  |> Email.put_subject("Hello from Elixir")
  |> Email.put_text("Sent with Elixir")

:ok = Mail.send(email)