https://github.com/willin/resend-cloudflare-service-worker
A Resend Email Service Worker For Cloudflare Workers/Pages Service Binding
https://github.com/willin/resend-cloudflare-service-worker
binding cloudflare resend service-worker worker
Last synced: about 1 month ago
JSON representation
A Resend Email Service Worker For Cloudflare Workers/Pages Service Binding
- Host: GitHub
- URL: https://github.com/willin/resend-cloudflare-service-worker
- Owner: willin
- License: mit
- Created: 2024-08-21T13:33:55.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T14:10:48.000Z (almost 2 years ago)
- Last Synced: 2024-10-26T15:16:55.457Z (over 1 year ago)
- Topics: binding, cloudflare, resend, service-worker, worker
- Language: TypeScript
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Resend Cloudflare Worker Service
[δΈζη](./README.zh-cn.md) / [English](./README.md)
## Prepare
1. `Use this template` to fork this repository to create your project
2. Set `Actions Secrets` in the project `Settings`, add the following environment variables:
```bash
### Only For Github Actions
CLOUDFLARE_ACCOUNT_ID="xxx"
CLOUDFLARE_API_TOKEN="xxx"
### Resend mail sending service, you can register for free sending
RESEND_API_KEY="re_xxxx"
### The username of the email sent
EMAIL_USERNAME="No-Reply "
### Address to receive test emails
TEST_EMAIL_ADDRESS="your@email.com"
```
## Use in Worker / Pages
Modify the `wrangler.toml` configuration in the project, add:
```toml
[[services]]
binding = "RESEND"
service = "email-sender-worker"
```
Then use in the code:
```ts
await ctx.env.RESEND.sendEmail({
to: ['address@example.com'], // or just a string
subject: 'Hello, World!',
html: '
Hello, World!
'
}); // returns b
```
Where the parameter of `sendEmail` is of type `SendEmailOptions`:
```ts
type SendEmailProps = {
to: string | string[];
subject: string;
html: string;
};
```
## Local Development
```bash
# npm, yarn, or pnpm
bun install
bun run dev
```
Then visit , a test email will be sent to `TEST_EMAIL_ADDRESS` mailbox.
## Sponsor
Donation ways:
- Github: [](https://github.com/willin)
- Alipay or Wechat Pay: [QRCode](https://user-images.githubusercontent.com/1890238/89126156-0f3eeb80-d516-11ea-9046-5a3a5d59b86b.png)
- ETH: `0x6D877f96198E55085CEb56097B099cc7bb814263`
## License
MIT