• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
cookiemonster0922

cookiemonster0922

emailSender

Public
HTTP endpoint that sends emails via Val Town MCP
Like
emailSender
Home
Code
2
README.md
H
main.ts
Environment variables
1
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
3/11/2026
Viewing readonly version of main branch: v5
View latest version
README.md

emailSender

HTTP endpoint called by the agentcr Cloudflare Worker to send outbound reply emails via Val Town's built-in email service.

How it works

EmailRoutingAgent (Cloudflare Durable Object)
    │  POST { secret, to, subject, text }
    ▼
emailSender  (this val — HTTP export)
    │  validates shared secret
    │  calls Val Town std/email
    ▼
Reply email delivered to original sender

This val exists because Cloudflare Workers cannot send outbound emails directly without a verified sender domain on Cloudflare Email Routing. Val Town's std/email library handles delivery without any DNS setup.

Request format

POST to this val's endpoint with a JSON body:

{ "secret": "your-shared-secret", "to": "customer@example.com", "subject": "Re: Your enquiry", "text": "Plain-text reply body..." }

All four fields are required. The secret must match the EMAIL_SECRET environment variable.

Response

{ "ok": true }

On error:

{ "ok": false, "error": "error message" }

Security

  • Requests without a valid secret return 401 Unauthorized
  • The secret is never logged
  • The endpoint only accepts POST (OPTIONS for CORS preflight)

Environment variables

Set in Val Town → Project Settings → Environment Variables:

VariableDescription
EMAIL_SECRETShared secret — must match EMAIL_INBOUND_SECRET on the Cloudflare Worker

Cloudflare side

The worker calls this val via the VALTOWN_SEND_URL secret:

npx wrangler secret put VALTOWN_SEND_URL # this val's endpoint URL

The endpoint URL is shown in Val Town under the val's Endpoints tab.

Related vals

  • emailInboundHandler — receives inbound emails and forwards to the Cloudflare Worker
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
AboutAlternativesPricingBlogNewsletterCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.