{"id":29246934,"url":"https://github.com/timothydodd/mailvoid-cloudflare-worker","last_synced_at":"2025-10-24T22:37:48.925Z","repository":{"id":300623368,"uuid":"1006635988","full_name":"timothydodd/mailvoid-cloudflare-worker","owner":"timothydodd","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-22T19:14:29.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-03T23:43:25.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timothydodd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-22T17:35:42.000Z","updated_at":"2025-06-22T19:14:32.000Z","dependencies_parsed_at":"2025-06-22T19:45:19.775Z","dependency_job_id":null,"html_url":"https://github.com/timothydodd/mailvoid-cloudflare-worker","commit_stats":null,"previous_names":["timothydodd/mailvoid-cloudflare-worker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/timothydodd/mailvoid-cloudflare-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timothydodd%2Fmailvoid-cloudflare-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timothydodd%2Fmailvoid-cloudflare-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timothydodd%2Fmailvoid-cloudflare-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timothydodd%2Fmailvoid-cloudflare-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timothydodd","download_url":"https://codeload.github.com/timothydodd/mailvoid-cloudflare-worker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timothydodd%2Fmailvoid-cloudflare-worker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280878345,"owners_count":26406641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-03T23:39:15.397Z","updated_at":"2025-10-24T22:37:48.896Z","avatar_url":"https://github.com/timothydodd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mailvoid Cloudflare Worker\n\nA Cloudflare Worker that forwards incoming emails to your Mailvoid API.\n\n## Setup\n\n1. Install dependencies:\n```bash\nnpm install\n```\n\n2. Configure your environment variables in Cloudflare Dashboard or via Wrangler:\n```bash\nwrangler secret put MAILVOID_API_URL\nwrangler secret put MAILVOID_API_KEY\n```\n\n3. Update `wrangler.toml` with your domain and email routing settings.\n\n4. Deploy the worker:\n```bash\nnpm run deploy\n```\n\n## Development\n\nRun locally:\n```bash\nnpm run dev\n```\n\n## Testing\n\n### 1. Local Testing\nRun the test script:\n```bash\nnode test-email.js\n```\n\n### 2. Wrangler Dev with Email Simulation\nStart dev server:\n```bash\nwrangler dev\n```\n\n### 3. Production Testing\nAfter deployment, test with real emails by:\n- Setting up email routing in Cloudflare Dashboard\n- Sending test emails to your configured domain\n- Monitoring logs: `wrangler tail`\n\n### 4. API Testing\nUse curl to test your Mailvoid API endpoint directly:\n```bash\ncurl -X POST your-mailvoid-api-url \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer your-api-key\" \\\n  -d '{\"from\":\"test@example.com\",\"to\":\"test@yourdomain.com\",\"subject\":\"Test\"}'\n```\n\n## Configuration\n\nThe worker expects these environment variables:\n- `MAILVOID_API_URL`: Your Mailvoid API endpoint\n- `MAILVOID_API_KEY`: Your Mailvoid API authentication key\n\n## Email Routing\n\nConfigure email routing in your Cloudflare Dashboard under Email Routing to forward emails to this worker.\n\n## Cloudflare Workers Email API\n\nThe Cloudflare Workers email message object provides these properties and methods:\n\n### Message Properties\n- `message.from` - Sender's email address (string)\n- `message.to` - Recipient's email address (string)  \n- `message.headers` - Headers object with all email headers\n- `message.raw` - ReadableStream of the full raw email content\n- `message.rawSize` - Size of the email message content (number)\n\n### Message Methods\n- `message.setReject(reason)` - Reject the email with a specific reason\n- `message.forward(rcptTo, headers)` - Forward the email to another address\n- `message.reply(EmailMessage)` - Reply to the sender with a new email\n\n### Content Extraction\nSince there are no direct `.text()` or `.html()` methods, the worker reads from `message.raw` stream and parses the content using regex patterns to extract:\n- Plain text content from `Content-Type: text/plain` sections\n- HTML content from `Content-Type: text/html` sections\n\n### Data Mapping to EmailModel\nThe worker maps Cloudflare email data to your EmailModel structure:\n```json\n{\n  \"headers\": \"JSON string of all headers\",\n  \"dkim\": \"DKIM-Signature header value\",\n  \"to\": \"recipient@domain.com\",\n  \"html\": \"HTML content or null\",\n  \"from\": \"sender@domain.com\", \n  \"text\": \"Plain text content or null\",\n  \"sender_Ip\": \"X-Originating-IP or X-Sender-IP header\",\n  \"spf\": \"Received-SPF header value\",\n  \"attachments\": null,\n  \"subject\": \"Email subject\",\n  \"envelope\": \"JSON string with to/from arrays\",\n  \"charsets\": \"Charset from Content-Type header\",\n  \"createdOn\": \"ISO timestamp\",\n  \"spam_Score\": \"X-Spam-Score header value\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimothydodd%2Fmailvoid-cloudflare-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimothydodd%2Fmailvoid-cloudflare-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimothydodd%2Fmailvoid-cloudflare-worker/lists"}