Lambda function to send emails using the Brevo (SendinBlue) API.
-
Clone this repository:
git clone https://github.com/damanmokha/lambda-brevo.git
-
Install the required dependencies:
npm install
or
yarn install
-
Install and set up the AWS CLI. If you haven't installed it yet, you can follow the official guide here .
-
Configure AWS CLI with your access credentials:
aws configure
It will ask for AWS Access Id & Secret key along with default region keep those handy.
Create an IAM Role in AWS with the necessary permissions. The role should have full access to AWS Lambda. For detailed steps, you can follow the official guide here.
- Create a ZIP file of the necessary files:
zip -r brevo-lambda.zip node_modules/ index.js
- Create a Lambda function:
aws lambda create-function \ --function-name BrevoLambdaFunction \ --runtime nodejs14.x \ --role YOUR_IAM_ROLE_WITH_LAMBDA_ACCESS_ARN \ --handler index.handler \ --zip-file fileb://brevo-lambda.zip
-
Update the Lambda function code by creating a new ZIP file:
zip -r brevo-lambda.zip node_modules/ index.js
-
Update the Lambda function code:
aws lambda update-function-code \ --function-name BrevoLambdaFunction \ --zip-file fileb://brevo-lambda.zip
- Set up environment variables in the Lambda function:
BREVO_API_KEY: Your Brevo (SendinBlue) API key.
Your Lambda function URL will be the endpoint for sending emails via the Lambda function using Brevo. This URL can be generated in configuration tab of your lambda function. Make sure to configure Function url for public access or enable authentication as needed.
POST https://your-api-gateway-url/your-resource
Content-Type: application/json
{
"email": "[email protected]",
"name": "John Doe",
"content": "This is the email content."
}
Replace https://your-api-gateway-url/your-resource with the actual URL of your deployed API Gateway resource.
This completes the setup for your Lambda function to send emails using the Brevo (SendinBlue) API. Remember to secure your API and credentials appropriately and adjust configurations as needed for your specific use case.
Replace placeholders like `your-username`, `YOUR_IAM_ROLE_WITH_LAMBDA_ACCESS_ARN`, and update URLs and other specific details as needed.
This package is open-sourced software licensed under the MIT license.
Feel free to fork, clone, or use this demo application as a reference for implementing OTP verification in your Laravel projects.