This repository contains a serverless backend deployed to AWS Lambda, designed to handle email sending through SendGrid.
This backend function receives HTTP requests containing contact form data (name, email, message) and sends an email to a specified recipient using SendGrid. The function includes CORS handling to allow requests from specified origins.
- AWS Account
- SendGrid Account and API Key
- Node.js
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Set up environment variables:
SENDGRID_API_KEY
: Your SendGrid API key.EMAIL_TO
: The email address to which the messages will be sent.
These variables can be set in the AWS Lambda console or through your deployment pipeline.
- Email Sending: Uses the SendGrid API to send emails based on data received in the request.
- Error Handling: Provides meaningful error messages and logs errors for debugging.
Deploy the Lambda function using the AWS Lambda console, AWS CLI, or a deployment framework such as the Serverless Framework.