top of page
SendGrid npm Integration

SendGrid npm Integration

Use SendGrid’s npm module to send emails from your site

Intermediate.png

Intermediate

3K

Published:

November 8, 2020

Girl Enjoying her Drink

by

Anchor 1
Hire a Developer

Example Description

In this example, we integrate the SendGrid 3rd-party service with our site, allowing you to send emails using a form directly from the browser.

 

Notes:

  • To use this example, you must first create a SendGrid account and get an API key.

  • You must store the API key and the sender email address that you associated with the SendGrid account in the Secrets Manager (see details below).

Example Code

Tab 1

.

Tab 2

.

Tab 3

.

This code solution can be complicated.

How We Built It


Page Elements


We added a form with the following elements:

  • 3 text inputs: For the recipient’s email address, subject line, and body of the email.

  • Button: For sending the email.

  • Text element: For displaying success and error messages.


Secrets Manager


We saved the email address associated with our SendGrid account and our SendGrid API key in the Secrets Manager:

  • Secret name: sendGridSecret

  • Secret value:{"key": <my-sendgrid-api-key>, "senderEmail": <my-verified-sender-email>}


npm package


 

Code

 

Our site code does the following:

  1. When a site visitor clicks the Send button, check whether all input fields are valid.

  2. If an input field is invalid, display an error message.

  3. If the input fields are valid, call a backend function.

  4. The backend function gets the secret from the Secrets Manager and then sends the email with the email data entered in the form.

APIs We Used

Non-code example.

Non-code example.

Non-code example.

Related Articles

Hire a Developer

Velo solutions are powerful tools, but building them on your own can be challenging. Let an experienced Velo development shop build it for you, so you can keep working on your site or business.

Related Examples

Did this help?

Yes

|

No

Thanks for your feedback!

Save Data to a Google Sheet Using npm

Save Data to a Google Sheet Using npm

Reveal sections of a hidden video on hover.

Intermediate.png

Intermediate

Send Email with the SendGrid REST Interface

Send Email with the SendGrid REST Interface

Use the wix-fetch API to send an email using the SendGrid REST API.

Intermediate.png

Intermediate

Twilio Integration

Twilio Integration

Integrate with Twilio to make voice calls and send SMS messages

Intermediate.png

Advanced

Anchor 2
bottom of page