Skip to main content

Prerequisites

To get the most out of this guide, you’ll need to:
You can find your API keys in your SendPost Dashboard. Make sure to use your Sub-Account API Key for sending emails.

1. Install Dependencies

npm

2. Project Structure

Create a Netlify function:
Or if using TypeScript:

3. Basic Email Function

Create netlify/functions/send-email.js:
JavaScript

TypeScript Version

Create netlify/functions/send-email.ts:
TypeScript

4. Environment Variables

Create netlify.toml:
Or set in Netlify Dashboard:
  1. Go to Site settings → Environment variables
  2. Add SENDPOST_API_KEY

5. Common Use Cases

Welcome Email Function

Create netlify/functions/welcome-email.js:
JavaScript

6. Testing Locally

Install Netlify CLI:
Run locally:
Test your function:

7. Deploy

Deploy to Netlify:
Or connect your Git repository for automatic deployments.
Make sure your sender email domain is verified in your SendPost account before sending emails.

8. Next Steps

Explore more examples and use cases:

Netlify Functions

Learn more about Netlify Functions

SendPost JavaScript SDK

View the official SDK package on npm

Quickstart Example

View a complete working example on GitHub