Mailman is a project that sends contact form data in an email to a specified recipient using Cloudflare Workers and Cloudflare Email Routing.
- Cloudflare account with Email Routing enabled.
- Verified email addresses in Cloudflare Email Routing.
index.ts
: Main worker script to handle incoming requests and send emails.wrangler.toml
: Configuration file for the Cloudflare Worker.
-
Clone the repository and intall dependencies:
git clone https://github.com/your-username/mailman.git cd mailman npm install
-
Set emails in
wrangler.toml
:[vars] SENDER = "sender@example.com" RECIPIENT = "verified_recipient@example.com"
-
Start the development server:
npm run dev
-
Deploy the worker:
npm run deploy
Mailman accepts POST requests with form data as the body. By default, the form fields include firstName
, lastName
, email
, and message
.
<form action="https://your-worker-url.workers.dev" method="POST">
<label for="firstName">First Name:</label>
<input type="text" id="firstName" name="firstName" required>
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" name="lastName" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="reason">Reason:</label>
<textarea id="reason" name="reason" required></textarea>
<button type="submit">Send Message</button>
</form>
You can also send a POST request using curl
:
curl -X POST https://your-worker-url.workers.dev \
-d "firstName=John&lastName=Doe&email=john.doe@example.com&reason=Just%20saying%20hi!"
This project is licensed under the MIT License.
Feel free to contribute to this project by opening issues or submitting pull requests on GitHub.