> For the complete documentation index, see [llms.txt](https://reloaderlev.gitbook.io/russian-goit-node-js-new-program/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reloaderlev.gitbook.io/russian-goit-node-js-new-program/email-rassylka/sendgrid.-otpravka-email-ov-cherez-paket-sendgrid-mail.md).

# SendGrid. Отправка email-ов через пакет @sendgrid/mail

Теперь мы можем отправлять мейлы с Node.js кода. Для этого установим пакет @sendgrid/mail.

Для того, чтобы протестировать отправку email'у, пропишем следующий код, заменив `<email_отправитель>`, `<email_адресат>` и `<API_токен>`,  на соответственно созданные нами email-отправитель, email-адресат и создан API-токен:

```
const sgMail = require("@sendgrid/mail");

sgMail.setApiKey(<API_токен>);
const msg = {
  to: <email_адресат>,
  from: <email_отправитель>,
  subject: "Sending with Twilio SendGrid is Fun",
  text: "and easy to do anywhere, even with Node.js",
  html: "<strong>and easy to do anywhere, even with Node.js</strong>",
};

async function main() {
  const [response] = await sgMail.send(msg);

  console.log(response);
}

main();
```
