Mailbay for vibe coders
Your AI built the app. Now give it email.
Paste one prompt into your AI builder. It tells the AI exactly which endpoint to call, where the key lives and which address to send from, so the result works on the first try more often.
What gets in the way
The app works, but sign up emails never arrive or land in spam, and you are not sure where the email code should even go.
How it goes
- 1
Verify your domain and make a key
In Mailbay: add your domain, publish the records it lists, create a Sending only key.
noreply@yourapp.com verified - 2
Paste the prompt
Into Lovable, Bolt, v0, Replit or Cursor. It adds a server side helper and wires your sign up and contact flows.
Add email to this app using Mailbay... - 3
Set two env vars
MAILBAY_API_KEY and MAILBAY_FROM, in your builder's secrets. Send a test to delivered@test.mailbay.dev.
MAILBAY_API_KEY MAILBAY_FROM
The prompt
Copy it as it is, then change step 3 to name the emails your app needs.
Add email to this app using Mailbay (https://mailbay.dev). Use only the API facts below; do not guess other endpoints or fields.
Mailbay API:
- Send: POST https://api.mailbay.dev/v1/emails (if MAILBAY_API_URL is set, use it instead of https://api.mailbay.dev)
- Header: Authorization: Bearer <MAILBAY_API_KEY>, Content-Type: application/json
- Body: { "from": "Name <address>", "to": "person@example.com" (or an array), "subject": "...", "html": "...", "text": "..." }. Optional: "cc", "bcc", "reply_to".
- Success: HTTP 200 with { "id": "eml_..." }.
- Errors: a non 2xx status with { "error": { "code": "...", "message": "...", "fix": "..." } }. The fix says what to change.
- "from" must be an address on a domain verified in my Mailbay account. Read it from MAILBAY_FROM, such as "Acme <noreply@acme.com>".
- Optional header Idempotency-Key: a retry with the same key returns the first result instead of sending twice.
- To test without emailing real people, send to delivered@test.mailbay.dev.
What to do:
1. Read MAILBAY_API_KEY and MAILBAY_FROM from environment variables, on the server only. Never send the key to the browser: no NEXT_PUBLIC_, VITE_ or similar prefix, no client components or client bundles. Add both names to .env.example with placeholder values.
2. Write one server side helper, sendEmail({ to, subject, html, text }), that calls the endpoint above and throws an error containing error.code and error.fix when the response is not ok.
3. Use it where this app should send email: a welcome email after sign up, and a notification for any contact or support form. Keep the emails short and plain.
4. If this app uses Supabase Auth (sign up confirmation, magic links, password resets), do not send those from code. Tell me to turn on custom SMTP in Supabase instead: host smtp.mailbay.dev, port 465, username mailbay, password a Mailbay API key that can send, sender email on my verified domain.
5. Finish by listing the environment variables I need to set and where to set them.Tested in Claude Code 2.1.299 on a small Next.js app: it wrote a server only helper and wired sign up and contact, and both emails were delivered. Not yet tested in Lovable, Bolt, v0 or Replit, so treat it as a prompt to adapt there.
Works with what you use
Every tool, with what we tested, is in the integrations directory.
What you get
The key stays on the server
The prompt forbids public env prefixes and client code, the most common way AI built apps leak keys.
Auth emails through SMTP
Built on Supabase? Sign up and reset emails go through Supabase's custom SMTP, not your code.
Supabase Auth guideFrom your own domain
SPF, DKIM and DMARC are set when you verify the domain, which is what keeps mail out of spam folders.
Test without real people
delivered@, bounced@ and complained@test.mailbay.dev simulate each outcome.
Errors your AI can read
Every error comes back as JSON with a code and a fix, so the AI can correct itself.
Questions
Which AI builders does the prompt work with?
It is written for any of them: Lovable, Bolt, v0, Replit and Cursor. We tested it in Claude Code on a Next.js app, where it worked as written; we have not run it in the others yet, so adapt it if your tool answers differently.
Do I need to understand the code it writes?
No, but check two things: the key is only read on the server, and the from address is on the domain you verified. The prompt asks the AI to list the environment variables you need to set.
Why do my app's emails land in spam?
Usually because they are sent from a domain without SPF, DKIM and DMARC. Verify your domain in Mailbay, then send one email to the free deliverability test to see what passes.
Can I use MCP instead of a prompt?
Yes, if your tool supports MCP, as Cursor and Claude Code do. The MCP server gives the AI inboxes and sending tools; the prompt is for adding email to the app itself.
Want the long version? Read the free email deliverability test and Cursor's MCP setup, or see who else Mailbay is for.
Join the beta
Mailbay is in private beta and free while the beta runs: inboxes, sending, your own domains and MCP. We invite people in small batches and read every note on the form.