Cloudflare Worker that acts as a temporary email inbox.
API documentation: https://api.barid.site
AI-made web client: https://web.barid.site
- Receives emails via Cloudflare Email Routing.
- Stores email data in a Cloudflare D1 database.
- Attachment Support: Stores email attachments up to 50MB in Cloudflare R2.
- Provides comprehensive API endpoints for emails and attachments.
- Automatically cleans up old emails and attachments.
- Supports multiple file types including documents, images, and archives.
A big thank you to individuals who have donated domains to support this project. Your contributions help keep this service running.
| Domain | Donated by |
|---|---|
barid.site |
vwh |
vwh.sh |
vwh |
iusearch.lol |
vwh |
lifetalk.us |
mm6x |
z44d.pro |
z44d |
wael.fun |
blockton |
tawbah.site |
HprideH |
kuruptd.ink |
HprideH |
oxno1.space |
oxno1 |
hacktivc.com |
None |
lealaom.xyz |
None |
leala.site |
None |
If you have an unused domain and would like to contribute, you can donate it by following these steps:
- Create a Pull Request: Add your domain and owner information to
config/domains.tsfile insrcdirectory. - Nameserver Provisioning: After your pull request, we will provide you with nameservers to update for your domain.
Here are some projects built by the community using or integrating with Temp Mail Worker:
- Rust Library: doomed-neko/tmapi
- Go Library: blockton/barid
- Python Library: superhexa/barid-client
- CLI App: doomed-neko/tmcli
Before you begin, ensure you have following:
- Bun: Installed on your system.
- Cloudflare Account: With access to Workers, Email Routing, and D1.
-
Install Dependencies: Install necessary JavaScript dependencies.
bun install
-
Login to Cloudflare: You need to log in to your Cloudflare account via Wrangler. This will open a browser for authentication.
bun wrangler login
- Create D1 database**:
bun run db:create
- Copy
database_id: From output of above command. - Update
wrangler.jsonc: Openwrangler.jsoncand replacedatabase_idwithdatabase_idyou just copied. - Apply Database Schema:
bun run db:tables
- Apply Database Indexes:
bun run db:indexes
- Create R2 Bucket**:
bun run r2:create
- Create Preview Bucket (for development):
bun run r2:create-preview
- Go to your Cloudflare Dashboard: Select your domain (
example.com). - Navigate to "Email" -> "Email Routing".
- Enable Email Routing if it's not already enabled.
- Create a Catch-all Rule:
- For "Action", choose "Send to Worker".
- Select your Worker (e.g.,
temp-mail). - Click "Save".
To check your Cloudflare Workers, D1 databases, and domain information directly from your terminal, you can use the cf-info script.
-
Configure API Credentials: Add your Cloudflare Account ID and an API Token with appropriate permissions (e.g.,
Zone:Read,Worker Scripts:Read,D1:Read,Zone:Email:Read) to your.dev.varsfile.Example
.dev.varsadditions:CLOUDFLARE_ACCOUNT_ID="YOUR_CLOUDFLARE_ACCOUNT_ID" CLOUDFLARE_API_TOKEN="YOUR_CLOUDFLARE_API_TOKEN" -
Run Script**:
bun run cf-info
If you wish to enable Telegram logging for your worker, follow these steps:
-
Enable Logging in
wrangler.jsonc: EnsureTELEGRAM_LOG_ENABLEis set totruein yourwrangler.jsoncfile undervarssection. -
Local Development (
.dev.vars): For local development, create a.dev.varsfile in your project root with your Telegram bot token and chat ID. This file is used bybun dev.Example
.dev.vars:TELEGRAM_BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN" TELEGRAM_CHAT_ID="YOUR_TELEGRAM_CHAT_ID" -
Production Deployment (Secrets): For production, you must set
TELEGRAM_BOT_TOKENandTELEGRAM_CHAT_IDas secrets usingwrangler. This securely stores your sensitive information with Cloudflare.Run following commands in your terminal and enter respective values when prompted:
bun wrangler secret put TELEGRAM_BOT_TOKEN bun wrangler secret put TELEGRAM_CHAT_ID
To run worker locally:
bun run devTo deploy your worker to Cloudflare:
bun run deploybun run dev- Start local development serverbun run deploy- Deploy to Cloudflare Workersbun run tail- View live logs from deployed worker
bun run db:create- Create D1 databasebun run db:tables- Apply database schemabun run db:indexes- Apply database indexesbun run db:migrate-attachments- Add attachment support to existing database
bun run r2:create- Create R2 bucket for attachmentsbun run r2:create-preview- Create R2 preview bucket
bun run check- Run all linting and formatting checksbun run lint- Run ESLintbun run lint:fix- Fix ESLint issuesbun run format- Format code with Prettierbun run tsc- Run TypeScript compiler
bun run cf-info- Display Cloudflare account informationbun run cf-typegen- Generate TypeScript types for Cloudflare bindings
GET /emails/{emailAddress}- Get emails for a specific addressGET /emails/count/{emailAddress}- Get email count for a specific addressGET /inbox/{emailId}- Get a specific email by IDDELETE /emails/{emailAddress}- Delete all emails for a specific addressDELETE /inbox/{emailId}- Delete a specific email by IDGET /domains- Get list of supported domains
GET /emails/{emailAddress}/attachments- Get all attachments for emails sent to a specific addressGET /inbox/{emailId}/attachments- Get attachments for a specific emailGET /attachments/{attachmentId}- Download a specific attachmentDELETE /attachments/{attachmentId}- Delete a specific attachment
- File Size Limit: Up to 50MB per attachment
- File Count Limit: Up to 10 attachments per email
- Supported File Types:
- Images: JPEG, PNG, GIF, WebP, SVG
- Documents: PDF, TXT, CSV, Word, Excel, PowerPoint
- Archives: ZIP, RAR, 7Z
- Other: JSON, XML
GET /health- Service health status
For complete API documentation with examples, visit: https://api.barid.site