Markdown

Groundmail + Lovable

Lovable’s install surface is Secrets + a chat prompt: store your gm_ key, paste the prompt, and let Lovable wire server-side sends (often via Supabase Auth).

Updated Oct 23, 20262 min read

There is no separate Lovable “connector package.” The agent writes the Edge Function / hook against POST /emails (or SMTP if you prefer Supabase’s custom SMTP UI).

When to use Groundmail

  • Password reset, verification, receipts, and other transactional mail
  • Branded from on your own domain after DNS verify
  • Supabase Auth via a Send Email hook / Edge Function, or custom SMTP with a Groundmail credential

Lovable projects often use Supabase — see Supabase Auth email for the hook path and the SMTP alternative.

Add your API key (Secrets)

  1. Open app.groundmail.dev → API Keys → create a key (gm_…).
  2. In Lovable, open your project Settings → Secrets (or the env/secrets panel Lovable exposes for backend code).
  3. Add:
GROUNDMAIL_API_KEY=gm_your_key_here

Use the secret name exactly — server routes and Edge Functions should read process.env.GROUNDMAIL_API_KEY. Never put the key in client-side React components.

Paste this prompt in Lovable chat

Integrate Groundmail transactional email into this app.

Docs (read first):
- https://docs.groundmail.dev/llms.txt
- https://docs.groundmail.dev/ai/safe-defaults
- https://docs.groundmail.dev/guides/supabase
- https://docs.groundmail.dev/smtp
- https://docs.groundmail.dev/builders/lovable

Rules:
1. GROUNDMAIL_API_KEY is in Lovable Secrets. Use it only in a Supabase Edge Function or other server code, never in React components, and never log it.
2. Send with POST https://api.groundmail.dev/emails (header Authorization: Bearer $GROUNDMAIL_API_KEY; JSON fields from, to, subject, html, text, reply_to), or the "groundmail" npm package on Node (it throws GroundmailError on failure).
3. Give every send an Idempotency-Key header (SDK option: idempotencyKey) that is unique to the message, for example "password-reset-<userId>-<tokenId>", and reuse it if you retry.
4. Test first: send from "noreply@mail.groundmail.dev" to my Groundmail account email only. Do not email anyone else until I have verified a domain and added a payment method in Groundmail (the Free plan is not charged).
5. On an error, read error.code and error.hint from the JSON response and follow the hint (https://docs.groundmail.dev/errors). Retry only on 429, 500, 502 or 503, with backoff and the same Idempotency-Key.
6. Add a server-side send path for at least one real flow: password reset, email verification or a receipt.
7. If I prefer Supabase custom SMTP instead of the API: host smtp.groundmail.dev, port 587, username groundmail, password from an SMTP credential in the Groundmail dashboard.

When my domain is verified, switch from to an address on it, for example noreply@ourdomain.com.

If the agent asks for your account email, give it the email you sign in to Groundmail with.

Minimal server send (Node / Edge)

TypeScript
const res = await fetch('https://api.groundmail.dev/emails', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.GROUNDMAIL_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    from: 'noreply@yourdomain.com',
    to: 'user@example.com',
    subject: 'Verify your email',
    html: '<p>Click the link to verify.</p>',
  }),
})

Or install groundmail and use the SDK — see Next.js.

Sandbox self-test

Send to your Groundmail account email only, with from: "noreply@mail.groundmail.dev", until your domain is verified and Free production is unlocked (payment method on file):

JSON
{
  "from": "noreply@mail.groundmail.dev",
  "to": "YOUR_ACCOUNT_EMAIL",
  "subject": "Groundmail sandbox check",
  "html": "<p>It works.</p>"
}

Production

  1. Add your domain in the Groundmail dashboard.
  2. Apply DNS (Cloudflare integration or registrar credentials).
  3. Verify, add a payment method to unlock Free production (Free is never charged; you're only billed if you turn on pay as you go), then update from to an address on that domain.

Optional: MCP while you build

If you use Cursor (or another MCP client) alongside Lovable, connect hosted MCP at https://mcp.groundmail.dev/mcp with OAuth — see MCP server. That helps the coding agent; your Lovable app still needs Secrets (or SMTP) for runtime sends.

Was this page helpful?