# Sendgrid

Go through the setup flow to get API\_KEY

## Node

utils.js

```javascript
const sgMail = require("@sendgrid/mail");
sgMail.setApiKey(conf.get("SENDGRID_API_KEY"));
module.exports = {sgMail};
```

router/user.js

```javascript
const { sgMail } = require("../utils.js");

const msg = {
  to: "jsjfuentesj@gmail.com",
  from: {
    email: "friends.modulo@gmail.com",
    name: "Team Modulo"
  },
  dynamic_template_data: {
    article_link: req.body.url
  },
  template_id: "d-256323a1409f4afc8e1fa85682b248b3"
};
await sgMail.send(msg);
```

## [Elixir](https://hexdocs.pm/sendgrid/SendGrid.Email.html)

mix.exs

```elixir
{:sendgrid, "~> 2.0"}
```

config.exs

```elixir
config :sendgrid,
  api_key: "SENDGRID_API_KEY"
```

reactphoenix/email.ex

```elixir
defmodule ReactPhoenix.Email do
  alias SendGrid.Email
  alias SendGrid.Mail

  def test() do
    Email.build()
    |> Email.add_to("jsjfuentesj@gmail.com")
    |> Email.put_from("test@slingshow.com")
    |> Email.put_subject("Hello from Elixir")
    |> Email.put_text("Sent with Elixir")
    |> Mail.send()
  end
end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openai.gitbook.io/code-cheatsheets/all/apis/sendgrid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
