#Example #Sendgrid #Email #WebModules #ServerSide #backend #3rdPartyServices #fetch
Demonstrates
-
Web modules - server-side (backend) code
-
Accessing 3rd Party Services (using backend function)
-
Calling Server-side Code from the Front-end with Web Modules
-
fetch() in the wix-fetch API
Required for this example
In order to run this example in the editor, you will need a SendGrid account to supply your own SendGrid API key . Paste the key in the appropriate line in the sendGrid.js file.
The live demo of this example has an additional field for the your SendGrid API Key. To run the live demo , paste your API Key into the SendGrid API Key input field before clicking the Send Email button.
Links for this example
-
View the Live demo in a browser page
-
Open the Example template in the Wix Editor
About this example
This example demonstrates how to send an email using the popular 3rd party email processing service SendGrid. We start by setting up a simple form with all of the fields necessary to send an email. When the user completes the form, the user clicks the Send button to request that the email be sent. The fields are checked for validity, and if everything is OK, a post request is sent to SendGrid using fetch(). A Lightbox opens to notify the user of the emailâs transmission status (success or failure).
Sending an email using the SendGrid REST API involves using a backend web module and the wix-fetch API to call SendGrid. When clicking the Send Email button, the sendEmail web method (exported from the sendEmail web module, located in the Backend folder) is called. The sendEmail module uses the sendGrid module to perform the actual call to the SendGrid REST API via the wix-fetch HTTP API. âNote that you can replace the SendGrid API with any other Email API by providing a replacement for the sendGrid.js file .
For more information, see the tutorial How to Send an Email on Form Submission