mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
feat: add readme (#106)
This commit is contained in:
@@ -150,6 +150,8 @@ database_id = "xxx" # D1 数据库 ID
|
|||||||
|
|
||||||
部署
|
部署
|
||||||
|
|
||||||
|
第一次部署会提示创建项目, `production` 分支请填写 `production`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm run deploy
|
pnpm run deploy
|
||||||
```
|
```
|
||||||
@@ -162,6 +164,8 @@ pnpm run deploy
|
|||||||
|
|
||||||
## Cloudflare Email Routing
|
## Cloudflare Email Routing
|
||||||
|
|
||||||
|
在将电子邮件地址绑定到您的 Worker 之前,您需要启用电子邮件路由并拥有至少一个经过验证的电子邮件地址。
|
||||||
|
|
||||||
配置对应域名的 `电子邮件 DNS 记录`
|
配置对应域名的 `电子邮件 DNS 记录`
|
||||||
|
|
||||||
配置 `Cloudflare Email Routing` catch-all 发送到 `worker`
|
配置 `Cloudflare Email Routing` catch-all 发送到 `worker`
|
||||||
@@ -172,6 +176,8 @@ pnpm run deploy
|
|||||||
|
|
||||||
## Cloudflare Pages 前端
|
## Cloudflare Pages 前端
|
||||||
|
|
||||||
|
第一次部署会提示创建项目, `production` 分支请填写 `production`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd frontend
|
cd frontend
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ wrangler d1 execute dev --file=db/schema.sql
|
|||||||
|
|
||||||
### Backend - Cloudflare workers
|
### Backend - Cloudflare workers
|
||||||
|
|
||||||
|
The first deployment will prompt you to create a project. Please fill in `production` for the `production` branch.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd worker
|
cd worker
|
||||||
pnpm install
|
pnpm install
|
||||||
@@ -65,12 +67,18 @@ you can find and test the worker's url in the workers dashboard
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Cloudflare Email Routing
|
||||||
|
|
||||||
|
Before you can bind an email address to your Worker, you need to enable Email Routing and have at least one verified email address.
|
||||||
|
|
||||||
enable email route and config email forward catch-all to the worker
|
enable email route and config email forward catch-all to the worker
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Frontend - Cloudflare pages
|
### Frontend - Cloudflare pages
|
||||||
|
|
||||||
|
The first deployment will prompt you to create a project. Please fill in `production` for the `production` branch.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd frontend
|
cd frontend
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|||||||
+1
-11
@@ -8,18 +8,8 @@ async function email(message, env, ctx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!env.PREFIX || (message.to && message.to.startsWith(env.PREFIX))) {
|
if (!env.PREFIX || (message.to && message.to.startsWith(env.PREFIX))) {
|
||||||
const reader = message.raw.getReader();
|
const rawEmail = await new Response(message.raw).text();
|
||||||
const decoder = new TextDecoder("utf-8");
|
|
||||||
let rawEmail = "";
|
|
||||||
while (true) {
|
|
||||||
const { done, value } = await reader.read();
|
|
||||||
if (done) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
rawEmail += decoder.decode(value);
|
|
||||||
}
|
|
||||||
const message_id = message.headers.get("Message-ID");
|
const message_id = message.headers.get("Message-ID");
|
||||||
|
|
||||||
// save email
|
// save email
|
||||||
const { success } = await env.DB.prepare(
|
const { success } = await env.DB.prepare(
|
||||||
`INSERT INTO raw_mails (source, address, raw, message_id) VALUES (?, ?, ?, ?)`
|
`INSERT INTO raw_mails (source, address, raw, message_id) VALUES (?, ?, ?, ?)`
|
||||||
|
|||||||
Reference in New Issue
Block a user