Prompt

building a multi-environment email setup for dev staging prod

Technology / API Platforms1 observationLast seen Oct 13, 2026

Latest observation

Oct 13, 2026OpenAI APIWeb search: off

Here’s a practical way to set up multi-environment email for dev / staging / prod without accidentally spamming real users.

Recommended pattern

1) Use separate email configs per environment

Each environment should have its own:

  • SMTP/API credentials
  • From address
  • Reply-to
  • Mail provider settings
  • Recipient restrictions

Example:

  • dev: use a sandbox provider or local mail catcher
  • staging: use a test inbox/domain or provider sandbox
  • prod: real provider and real delivery

Suggested environment behavior

Dev

Goal: safe testing, no real emails.

Options:

  • Mailtrap
  • MailHog
  • Papercut
  • Local SMTP catcher

Typical setup:

  • intercept outgoing mail
  • display in a UI or logs
  • no external delivery

Staging

Goal: test actual email flow, but still safe.

Options:

  • email provider sandbox mode
  • send only to internal test accounts
  • rewrite all recipients to a test inbox
  • use a staging-only domain like staging.example.com

Typical setup:

  • real templates
  • real rendering
  • deliverability checks
  • no customer-facing sends

Prod

Goal: reliable delivery to real users.

Use:

  • verified sending domain
  • SPF, DKIM, DMARC
  • production API keys
  • monitoring/bounce handling

Core best practices

1) Centralize email sending

Have one abstraction like:

  • EmailService
  • Mailer
  • NotificationSender

Then switch behavior by environment.

2) Guard recipients in non-prod

A strong safety mechanism:

  • dev/staging should never send to arbitrary external addresses
  • either:
    • block sending outside an allowlist
    • rewrite all recipients to one internal inbox
    • use provider sandbox

3) Use environment-specific templates

At minimum, environment-specific:

  • branding
  • footer text
  • links
  • asset URLs

Example:

  • dev links point to dev app
  • staging links point to staging app
  • prod links point to production app

4) Separate domains/subdomains

Recommended:

  • dev-mail.example.com
  • staging-mail.example.com
  • mail.example.com

Or at least:

  • no-reply@dev.example.com
  • no-reply@staging.example.com
  • no-reply@example.com

5) Manage secrets properly

Store credentials in:

  • environment variables
  • secret manager
  • CI/CD protected variables

Do not hardcode:

  • SMTP passwords
  • API keys
  • provider tokens

Example config structure

# common
APP_ENV=staging

# dev
DEV_MAIL_PROVIDER=mailhog
DEV_MAIL_HOST=localhost
DEV_MAIL_PORT=1025

# staging
STAGING_MAIL_PROVIDER=sendgrid
STAGING_MAIL_API_KEY=...
STAGING_MAIL_FROM=no-reply@staging.example.com
STAGING_MAIL_ALLOWLIST=test1@company.com,test2@company.com

# prod
PROD_MAIL_PROVIDER=sendgrid
PROD_MAIL_API_KEY=...
PROD_MAIL_FROM=no-reply@example.com

Safety rules I’d recommend

For dev and staging:

  • block unknown recipients
  • strip production webhooks/callbacks
  • disable unsubscribe processing if needed
  • tag emails with environment headers:
    • X-Environment: staging

For prod:

  • enable bounces and complaints handling
  • monitor send rates
  • alert on failures
  • verify domain authentication

Testing checklist

Dev

  • email renders
  • links are correct
  • attachments work
  • no real delivery

Staging

  • sandbox or allowlist works
  • templates match prod
  • provider integration works
  • tracking/bounces not broken

Prod

  • deliverability verified
  • DNS records correct
  • reply handling works
  • monitoring in place

A simple implementation approach

Pseudo-logic:

if (env === 'dev') {
  useLocalSMTP();
} else if (env === 'staging') {
  useSandboxOrAllowlist();
} else {
  useProductionProvider();
}

And always include a recipient guard:

if (env !== 'prod' && !allowedRecipients.includes(to)) {
  throw new Error('Blocked non-prod email recipient');
}

My recommendation

If you want the cleanest setup:

  • Dev: MailHog or Mailtrap
  • Staging: provider sandbox or recipient allowlist
  • Prod: real provider with authenticated domain
  • One shared mailer abstraction
  • Recipient guard rails everywhere

If you want, I can also give you:

  1. a Node.js / Python / Rails / Django example,
  2. a Terraform/DNS checklist for SPF/DKIM/DMARC,
  3. or a full architecture diagram for this setup.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.