Package Exports
- worker-mailer
- worker-mailer/dist/index.js
- worker-mailer/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (worker-mailer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Worker Mailer
Worker Mailer is an SMTP client that runs on Cloudflare Workers. It leverages Cloudflare TCP Sockets and doesn't rely on any other dependencies.
Features
- Completely built on the Cloudflare Workers runtime with no other dependencies
- Full TypeScript type support
- Supports sending plain text and HTML emails
- Supports
plain,login, andCRAM-MD5SMTP authentication
Getting Started
Installation
npm i worker-mailer@betaUsage
In your wrangler.toml, configure the following:
compatibility_flags = ["nodejs_compat"]
import { WorkerMailer } from 'worker-mailer'
const mailer = await WorkerMailer.connect({
credentials: {
username: 'bob@acme.com',
password: 'password',
},
authType: 'plain',
host: 'smtp.acme.com',
port: 587,
secure: true,
})
await mailer.send({
from: { name: 'Bob', email: 'bob@acme.com' },
// from: 'bob@acme.com'
subject: 'Test email',
text: 'Plain message',
// html: '<p>HTML message</p>',
to: { name: 'Alice', email: 'alice@acme.com' },
// to: [{ name: 'Alice', email: 'alice@acme.com' }, { name: 'Sam', email: 'sam@acme.com' }]
// to: 'alice@acme.com'
})For more API details, check out the TypeScript declaration file dist/index.d.ts.
Limitations and Known Issues
- Port Restrictions: Cloudflare Workers cannot make outbound connections on port 25. You won't be able to send emails via port 25, but common ports like 587 and 465 are supported.
- Beta Stage: This library is currently in beta and is under rapid development. There might be bugs, and there's still a lot of unit testing to be done.
Contributing
We welcome your contributions! If you encounter any issues or have suggestions while using this library, feel free to open an issue on our GitHub repository.