You can deploy this function on any of the serverless platforms - AWS Lambda, Google Cloud Functions, Azure Functions, Netlify, Cloudflare Workers, etc.
- Create a new function and paste in the following code.
- You will need to add
nodemailerto yourpackage.json(npm i nodemailer), and follow your platform's instructions on bundling dependencies. - Obtain Gmail API credentials for your account. You will need
clientID,clientSecret, andrefreshToken. Follow this YouTube tutorial - Expose these credentials as the follwing environment variables:
GMAIL_EMAIL_ADDRESS