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 the 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 |
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 the
config/domains.ts
file in thesrc
directory. - Nameserver Provisioning: After your pull request, we will provide you with the 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 the following:
- Bun: Installed on your system.
- Cloudflare Account: With access to Workers, Email Routing, and D1.
-
Install Dependencies: Install the 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 the D1 database:
bun run db:create
- Copy the
database_id
: From the output of the above command. - Update
wrangler.jsonc
: Openwrangler.jsonc
and replacedatabase_id
with thedatabase_id
you just copied. - Apply Database Schema:
bun run db:tables
- Apply Database Indexes:
bun run db:indexes
- Create the KV Namespace:
bun run kv:create
- Copy the
id
: From the output of the above command. - Update
wrangler.jsonc
: Openwrangler.jsonc
and replaceid
andpreview_id
with theid
you just copied.
- Create the 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, KV namespaces, 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
,KV Storage:Read
,Zone:Email:Read
) to your.dev.vars
file.Example
.dev.vars
additions:CLOUDFLARE_ACCOUNT_ID="YOUR_CLOUDFLARE_ACCOUNT_ID" CLOUDFLARE_API_TOKEN="YOUR_CLOUDFLARE_API_TOKEN"
-
Run the 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_ENABLE
is set totrue
in yourwrangler.jsonc
file under thevars
section. -
Local Development (
.dev.vars
): For local development, create a.dev.vars
file 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_TOKEN
andTELEGRAM_CHAT_ID
as secrets usingwrangler
. This securely stores your sensitive information with Cloudflare.Run the following commands in your terminal and enter the respective values when prompted:
bun wrangler secret put TELEGRAM_BOT_TOKEN bun wrangler secret put TELEGRAM_CHAT_ID
To run the worker locally:
bun run dev
To deploy your worker to Cloudflare:
bun run deploy
bun 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 kv:create
- Create KV namespacebun 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