Skip to main content

Overview

This guide shows you how to integrate AutoSend with Supabase Edge Functions to send emails for authentication, notifications, and other transactional use cases. Edge Functions run at the edge, close to your users, making them perfect for handling email operations with low latency.
AutoSend has an official integration with Supabase. For a less technical setup, you can also use SMTP to integrate with Supabase.

Prerequisites

Before you begin, make sure you have:

Quickstart

1

Create a Supabase Edge Function

Initialize your Supabase project and create a new Edge Function:
This creates a new function in supabase/functions/autosend/index.ts.
2

Install Dependencies

Edge Functions support importing from standard URLs. No package installation needed!
3

Write the Edge Function

Replace the content of supabase/functions/autosend/index.ts with:
4

Create Shared CORS Configuration

Create a file at supabase/functions/_shared/cors.ts:
5

New Step

Create a .env file in your project root (for local development):
For production, set secrets using the Supabase CLI:
6

Run Locally

Test your function locally before deploying:
The function will be available at: http://localhost:54321/functions/v1/autosend
7

Test Your Function

Send a test request using cURL:
8

Deploy to Production

Once tested, deploy your function:
Your function will be available at:

Usage Examples

Integration with Supabase Auth

You can use AutoSend to send custom authentication emails by integrating with Supabase Auth Hooks.
1

Create Auth Hook Function

2

Implement Auth Hook Handler

3

Configure Auth Hook in Supabase

  1. Go to Authentication > Hooks in your Supabase dashboard
  2. Enable the “Send Email” hook
  3. Set the hook URL to your deployed function:
  4. Configure the secret (optional but recommended)
Now all Supabase Auth emails will be sent through AutoSend!

Error Handling

Implement robust error handling for production:

Best Practices

Always use environment variables for sensitive data:
Validate email formats before sending:
Protect your function from abuse:
Always send from verified domains in AutoSend to ensure deliverability.
Learn how to verify domains →

Testing

Test Function Locally