### Install Dependencies with npm install Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/frontend/README.md Run in the project root to install all required dependencies as defined in package.json. ```sh npm install ``` -------------------------------- ### Install dependencies and configure environment for frontend deployment Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/cli/pages.md Commands to install frontend dependencies and create the production environment file. The first deployment will prompt to create a project; for the production branch, enter 'production'. ```bash cd frontend pnpm install cp .env.example .env.prod ``` -------------------------------- ### Install cf-temp-mail-agent-mail skill via npx skills, npx degit, or git clone Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/agent-email.md Three alternative installation methods for the cf-temp-mail-agent-mail skill. Option 1 uses npx skills (recommended, auto-detects multiple agents) with optional -g for global install. Option 2 uses npx degit to copy into the agent's skills folder. Option 3 clones the repo and copies the skill directory. Choose one method. ```bash # Option 1: npx skills (recommended, auto-detects multiple agents) npx skills add dreamhunter2333/cloudflare_temp_email --skill cf-temp-mail-agent-mail # Add -g to install globally npx skills add dreamhunter2333/cloudflare_temp_email --skill cf-temp-mail-agent-mail -g # Option 2: npx degit to copy into your agent's skills folder npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail /cf-temp-mail-agent-mail # Option 3: clone and copy git clone --depth 1 https://github.com/dreamhunter2333/cloudflare_temp_email.git /tmp/cf-temp-mail cp -r /tmp/cf-temp-mail/skills/cf-temp-mail-agent-mail / ``` -------------------------------- ### Run SMTP IMAP Proxy Server Locally Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/config-smtp-proxy.md Run the SMTP IMAP proxy server locally. Copy the .env.example file, create a virtual environment, install dependencies, and start the server. ```bash cd smtp_proxy_server/ # Copy configuration file and modify it # Your worker address, proxy_url=https://temp-email-api.xxx.xxx # Your SMTP service port, port=8025 cp .env.example .env python3 -m venv venv ./venv/bin/python3 -m pip install -r requirements.txt ./venv/bin/python3 main.py ``` -------------------------------- ### Enable STARTTLS with .env Configuration Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/config-smtp-proxy.md Example .env configuration to enable STARTTLS for SMTP and IMAP. Set the TLS certificate and key file paths. ```bash # .env example smtp_tls_cert=/path/to/cert.pem smtp_tls_key=/path/to/key.pem imap_tls_cert=/path/to/cert.pem imap_tls_key=/path/to/key.pem ``` -------------------------------- ### Install Wrangler and clone repository Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/cli.md Install Wrangler globally and clone the repository. Optionally switch to the latest tag or a specific branch before deployment. ```bash npm install wrangler -g git clone https://github.com/dreamhunter2333/cloudflare_temp_email.git # Switch to the latest tag or the branch you want to deploy. You can also use the main branch directly. # git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) ``` -------------------------------- ### Address allowlist configuration example Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/ai-extract.md Example allowlist entries showing exact match, domain wildcard, and user wildcard patterns. Only addresses matching these patterns will trigger Workers AI calls. ```text user@example.com *@mydomain.com admin*@company.com ``` -------------------------------- ### Install mail-parser-wasm Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/mail-parser-wasm/README.md Install the mail-parser-wasm package using pnpm. ```bash pnpm add mail-parser-wasm ``` -------------------------------- ### Install mail-parser-wasm and postal-mime Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/skills/cf-temp-mail-agent-mail/SKILL.md Installs the two parsing libraries used in the fallback parser. ```bash npm i mail-parser-wasm postal-mime ``` -------------------------------- ### Install mail-parser-wasm-worker Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/mail-parser-wasm/README.md Install the mail-parser-wasm-worker package using pnpm. ```bash pnpm add mail-parser-wasm-worker ``` -------------------------------- ### Initialize Worker Project Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/cli/worker.md Initialize the worker project by installing dependencies and copying the configuration template. ```bash cd worker pnpm install cp wrangler.toml.template wrangler.toml ``` -------------------------------- ### Install Wrangler CLI Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/cli/pre-requisite.md Installs the Wrangler CLI globally using npm, which is required for deploying Cloudflare Workers. ```bash npm install wrangler -g ``` -------------------------------- ### ENV configuration example for frontend Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/frontend-vars.md Example of frontend ENV variables for CLI, Worker Assets, or Page Functions deployments. Add to frontend/.env.prod for CLI, frontend/.env.pages.local for Worker Assets/Page Functions, or the FRONTEND_ENV repository secret for the 'Deploy Frontend' GitHub Actions workflow. VITE_API_BASE is required only when frontend and backend are deployed separately. ```ini VITE_API_BASE=https://temp-email-api.example.com VITE_DEFAULT_LANG=en ``` -------------------------------- ### Quick Start Commands Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/e2e/README.md Commands to run E2E tests and clean up containers. `npm test` builds and runs all services, while `npm run test:down` cleans up. ```bash cd e2e # Build, start all services, run tests, and exit npm test # Clean up containers and volumes npm run test:down ``` -------------------------------- ### SMTP_CONFIG JSON example Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/config-send-mail.md This JSON defines SMTP settings for multiple domains. The key must be your own sending domain (e.g., your-domain.com) and must match a domain in DOMAINS. Replace the example values with your actual SMTP credentials. ```json { "your-domain.com": { "host": "smtp.example.com", "port": 465, "secure": true, "authType": [ "plain", "login" ], "credentials": { "username": "your-smtp-username", "password": "your-smtp-password" } }, "domain-b.com": { "host": "smtp.gmail.com", "port": 465, "secure": true, "authType": ["plain", "login"], "credentials": { "username": "user@gmail.com", "password": "app-password" } } } ``` -------------------------------- ### SMTP_IMAP_PROXY_CONFIG JSON example Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/worker-vars.md Example configuration for the SMTP_IMAP_PROXY_CONFIG environment variable, showing separate SMTP and IMAP hostnames and ports, useful for reverse proxies or separate port mappings. ```json { "smtp": { "host": "smtp.example.com", "port": 8025, "starttls": true }, "imap": { "host": "imap.example.com", "port": 11143, "starttls": true } } ``` -------------------------------- ### SUBDOMAIN_FORWARD_ADDRESS_LIST configuration example Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/worker-vars.md Example TOML configuration for the SUBDOMAIN_FORWARD_ADDRESS_LIST variable. It defines a list of forwarding rules with optional sourcePatterns and sourceMatchMode fields. The sourcePatterns filter by sender address regex, and sourceMatchMode can be 'any' (default) or 'all'. Regex patterns are limited to 200 characters to prevent ReDoS attacks. ```toml SUBDOMAIN_FORWARD_ADDRESS_LIST = """ [ {"domains":[""],"forward":"xxx1@xxx.com"}, {"domains":["subdomain-1.domain.com","subdomain-2.domain.com"],"forward":"xxx2@xxx.com"}, {"domains":["example.com"],"forward":"admin@xxx.com","sourcePatterns":[".*@github.com",".*@gitlab.com"],"sourceMatchMode":"any"} ] """ ``` -------------------------------- ### Compile and Hot-Reload for Development with npm run dev Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/frontend/README.md Starts the Vite development server with hot module replacement. ```sh npm run dev ``` -------------------------------- ### Admin Mail API with address filter via GET /admin/mails Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/mail-api.md Python example showing a GET request to the /admin/mails endpoint with limit, offset, and optional address query parameters. Requires x-admin-auth header with the admin password. The response is printed as JSON. The API returns raw MIME data, so parse the content client-side for readable subject/body. ```python import requests url = "https:///admin/mails" querystring = { "limit":"20", "offset":"0", # address is optional parameter "address":"xxxx@awsl.uk" } headers = { "x-admin-auth": "", # "x-custom-auth": "", # If private site password is enabled } response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` -------------------------------- ### Initialize D1 database with wrangler Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/cli/d1.md Copy the wrangler.toml template, create the D1 database 'temp-email-db', and execute the schema.sql file remotely. ```bash cd worker cp wrangler.toml.template wrangler.toml # Create D1 and execute schema.sql wrangler d1 create temp-email-db wrangler d1 execute temp-email-db --file=../db/schema.sql --remote ``` -------------------------------- ### View emails via Mail API with GET /api/mails Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/mail-api.md Python example using the requests library to fetch emails from the /api/mails endpoint with limit and offset parameters. Requires a JWT password for Authorization. Note that the API returns raw RFC822 data, so parse the source on the client side for readable content. ```python limit = 10 offset = 0 res = requests.get( f"https:///api/mails?limit={limit}&offset={offset}", headers={ "Authorization": f"Bearer {your-JWT-password}", # "x-custom-auth": "", # If private site password is enabled "Content-Type": "application/json" } ) ``` -------------------------------- ### Build and deploy frontend with page functions Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/cli/pages.md Commands to install dependencies, build with page functions (optionally disabling caching for Cloudflare Zero Trust), and deploy from the pages directory. The first deployment prompts to create a project; for production branch, enter 'production'. ```bash cd frontend pnpm install # If you want to enable Cloudflare Zero Trust, you need to use pnpm build:pages:nopwa to disable caching pnpm build:pages cd ../pages pnpm run deploy ``` -------------------------------- ### Build and deploy frontend with pnpm Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/google-ads.md Build and deploy the frontend after adding the Google Ads variables to frontend/.env.prod. On first deployment, you will be prompted to create a project and fill in 'production' for the production branch. ```bash pnpm build --emptyOutDir # For first deployment, you'll be prompted to create a project, fill in production for the production branch pnpm run deploy ``` -------------------------------- ### GET /user_api/address/:address_id/settings Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/send-mail-api.md Get the address and remaining send balance. ```APIDOC ## GET /user_api/address/:address_id/settings ### Description Get the address and remaining send balance. ### Method GET ### Endpoint /user_api/address/:address_id/settings ### Parameters #### Path Parameters - **address_id** (integer) - Required - The ID of the bound address #### Headers - **x-user-token** (string) - Required - User JWT for authentication ### Response No response schema is documented in the source. ``` -------------------------------- ### Build and deploy frontend to Cloudflare Pages Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/cli/pages.md Builds the frontend with empty output directory and deploys using wrangler pages deploy. The first deployment prompts to create a project; for production branch, enter 'production'. ```bash pnpm build --emptyOutDir # The first deployment will prompt you to create a project, for production branch enter production pnpm run deploy ``` -------------------------------- ### Create D1 database and KV namespace Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/cli.md Create a D1 database, execute the schema, and create a KV namespace. Copy the outputs to wrangler.toml. Use a database name like temp-email-db or cloudflare-temp-email-prod. ```bash # create a database, and copy the output to wrangler.toml in the next step wrangler d1 create temp-email-db wrangler d1 execute temp-email-db --file=db/schema.sql --remote # schema update, if you have initialized the database before this date, you can execute this command to update # wrangler d1 execute temp-email-db --file=db/2024-01-13-patch.sql --remote # wrangler d1 execute temp-email-db --file=db/2024-04-03-patch.sql --remote # create a namespace, and copy the output to wrangler.toml in the next step wrangler kv:namespace create DEV ``` -------------------------------- ### Get one parsed mail with curl Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/skills/cf-temp-mail-agent-mail/SKILL.md Get one parsed mail by its id. Replace with the actual mail id. ```bash curl -s "$BASE/api/parsed_mail/" -H "Authorization: Bearer $JWT" ``` -------------------------------- ### sendMailBody JSON example Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/skills/cf-temp-mail-agent-mail/SKILL.md Example body for POST /api/send_mail. from_name and to_name are optional (can be empty string). is_html: false sends plain text. ```json { "from_name": "My Name", "to_mail": "recipient@example.com", "to_name": "Recipient", "subject": "Hello", "content": "

Hi

", "is_html": true } ``` -------------------------------- ### Enable STARTTLS in Docker Compose Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/feature/config-smtp-proxy.md Docker Compose configuration to enable STARTTLS by mounting certificate files and setting environment variables. ```yaml environment: - smtp_tls_cert=/certs/cert.pem - smtp_tls_key=/certs/key.pem - imap_tls_cert=/certs/cert.pem - imap_tls_key=/certs/key.pem volumes: - ./certs:/certs:ro ``` -------------------------------- ### Compile and Minify for Production with npm run build Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/frontend/README.md Builds the application for production with minification. ```sh npm run build ``` -------------------------------- ### app-config in index.html for prebuilt frontend ZIP Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/guide/frontend-vars.md Example of the app-config JSON in index.html for prebuilt frontend ZIP deployments. Field names do not use the VITE_ prefix. Fields set here override ENV build values; omitted fields or a missing app-config tag fall back to ENV build values. ```html ``` -------------------------------- ### GET /api/sendbox Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/skills/cf-temp-mail-agent-mail/SKILL.md Lists sent emails (sendbox) with pagination. ```APIDOC ## GET /api/sendbox ### Description Lists sent emails (sendbox) with pagination. ### Method GET ### Endpoint /api/sendbox?limit=&offset= ### Query Parameters - **limit** (integer) - Optional - Number of items to return. - **offset** (integer) - Optional - Offset for pagination. ### Response #### Success Response (200) - **results** (array) - List of sent mail items. - **count** (integer) - Total number of sent items. #### Response Example { "results": [], "count": 0 } ``` -------------------------------- ### Deploy frontend to Cloudflare Pages Source: https://github.com/dreamhunter2333/cloudflare_temp_email/blob/main/vitepress-docs/docs/en/cli.md Deploy the frontend to Cloudflare Pages. The first deployment prompts you to create a project; fill in `production` for the `production` branch. Before building, add a `.env.local` file and set `VITE_API_BASE` to your worker's URL without a trailing slash. ```bash cd frontend pnpm install # add .env.local and modify VITE_API_BASE to your worker's url # VITE_API_BASE=https://xxx.xxx.workers.dev - don't put / in the end cp .env.example .env.local pnpm build --emptyOutDir pnpm run deploy ```