# Get started with SendPing and Supabase

> Send Supabase Auth and Edge Function emails through SendPing: verify your domain and call the HTTPS Email API from a Deno Edge Function or Auth Hook.

This guide gets you sending with SendPing from a Supabase project — first your **Auth emails** (password resets, confirmations), then arbitrary mail from **Edge Functions** (notifications, account activity).

## Set up SendPing

Before sending you must verify a domain. In the dashboard, add your domain — we recommend a [subdomain](https://www.sendping.co/docs/domains/managing) like `updates.example.com` — publish the generated DNS records with your provider, and wait for verification (usually a few minutes).

> **Note:** SendPing requires that you own the domain you send from (not a shared or public domain). Publishing the DNS records authorizes SendPing to send on your behalf and signals to inbox providers that you are a legitimate sender. See [Managing domains](https://www.sendping.co/docs/domains/managing).

## Send Auth emails through SendPing

Supabase rate-limits its built-in auth mailer. Route Supabase Auth email through a Send Email Hook that calls the SendPing HTTPS API:

- **Auth Hooks** — use a [Supabase Send Email Hook](https://supabase.com/docs/guides/auth/auth-hooks) to call SendPing yourself, giving you full control of the template (e.g. via [React Email](https://www.sendping.co/docs/kb/react-email-templates) or [SendPing Templates](https://www.sendping.co/docs/templates/overview)).

> **Note:** Supabase’s default auth rate limit is low; once SendPing is your provider you can raise it in your project’s authentication settings. Higher SendPing volume may also need a [quota increase](https://www.sendping.co/docs/kb/quotas).

## Send email from a Supabase Edge Function

For non-auth mail, call the SendPing API directly from an Edge Function with native `fetch`. First create the function with the Supabase CLI:

```bash
supabase functions new sendping
```

Then paste the handler into `index.ts`. Read the API key from an [Edge Function secret](https://supabase.com/docs/guides/functions/secrets) rather than hard-coding it:

**index.ts**

```ts
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';

const SENDPING_API_KEY = Deno.env.get('SENDPING_API_KEY')!;

serve(async (_req: Request): Promise<Response> => {
  const res = await fetch('https://www.sendping.co/api/emails', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${SENDPING_API_KEY}`,
    },
    body: JSON.stringify({
      from: 'Acme <hello@yourdomain.com>',
      to: ['delivered@yourdomain.com'],
      subject: 'hello world',
      html: '<strong>it works!</strong>',
    }),
  });

  const data = await res.json();
  return new Response(JSON.stringify(data), {
    status: res.status,
    headers: { 'Content-Type': 'application/json' },
  });
});
```

Set the secret, run the function locally, then deploy:

```bash
# store the key as a secret (never commit it)
supabase secrets set SENDPING_API_KEY=mb_xxxxxxxxx

# run locally
supabase functions serve sendping --no-verify-jwt

# deploy
supabase functions deploy sendping
```

> **Warning:** The `from` address must be on a [verified domain](https://www.sendping.co/docs/domains/managing). Keep your `mb_` key in a secret, not in source — see [Handling API keys securely](https://www.sendping.co/docs/kb/handling-api-keys).

For the request and response shape, see the [emails API](https://www.sendping.co/docs/api/emails-send).
