# SendGrid

Sign up for SendGrid

1. **Account Creation**: Sign up for a free SendGrid account to send up to 100 emails daily.
2. **Enable Two-Factor Authentication (2FA)**: Secure your account with 2FA via SMS or Authy app.
3. **Create API Key**: Generate a SendGrid API key for limited actions.
   * Use "Restricted Access" with "Mail Send" permissions set to "Full Access".
   * Store the API key securely in an environment variable (e.g., `SENDGRID_API_KEY`).
4. #### Verify Your Sender Identity

   Ensure legitimate sending behavior:\
   Links for reference.\
   <https://docs.sendgrid.com/for-developers/sending-email/sender-identity>\
   <https://docs.sendgrid.com/ui/account-and-settings/how-to-set-up-domain-authentication>
5. Here's a sample code block for creating( sending ) a message:

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

`sgMail.setApiKey(process.env.SENDGRID_API_KEY);`

`const msg = { to: 'test@example.com', // Change to your recipient from: 'test@example.com', // Change to your verified sender subject: 'Sending with SendGrid is Fun', text: 'and easy to do anywhere, even with Node.js', html: '`**`and easy to do anywhere, even with Node.js`**`', };`

`sgMail .send(msg) .then((response) => { console.log(response[0].statusCode); console.log(response[0].headers); }) .catch((error) => { console.error(error); });`

Run the `index.js` file with Node.js. If you see a 202 status code printed, the message was sent successfully. Check the recipient's inbox for the demo message. If not received, check the spam folder.

For troubleshooting, refer to the API response message documentation. Responses are in JSON format, specified by the Content-Type header. The Web API v3 provides response codes, content-type headers, and pagination options for interpreting API responses.<br>

**Here are some Email Formats**

&#x20;**Welcoming to our app** &#x20;

`{ "to": "recipient@example.com", "from": "sender@example.com", "subject": "Welcome to Our App!", "text": "Hello there! Welcome to our mobile app. We're excited to have you on board.", "html": "Hello there!Welcome to our mobile app. We're excited to have you on board." }`

&#x20;**Important Announcement**

```
{ "to": "user123@example.com", 
"from": "noreply@example.com", 
"subject": "Important Announcement", 
"text": "Dear User, we wanted to inform you about some important updates to our app. 
Please log in to your account for more details.", 
"html": "Dear User,We wanted to inform you about some important updates to our app.
 Please log in to your account for more details." }
```

### &#x20;Informing about Recent Purchase&#x20;

`{ "to": "customer@example.com", "from": "support@example.com", "subject": "Your Recent Purchase", "text": "Hi there! We wanted to confirm that your recent purchase has been successfully processed. Thank you for choosing our service.", "html": "Hi there!We wanted to confirm that your recent purchase has been successfully processed. Thank you for choosing our service." }`

// Password Reset Request { "to": "<user456@example.com>", "from": "<noreply@example.com>", "subject": "Password Reset Request", "text": "Dear User, we received a request to reset your password. If you did not initiate this request, please ignore this email. To reset your password, click on the following link: \[Password Reset Link]", "html": "

Dear User,

We received a request to reset your password. If you did not initiate this request, please ignore this email.

To reset your password, click on the following link: \<a href="\[Password Reset Link]">Reset Password

" }


---

# 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://docs.flutfast.com/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.
