diff --git a/demo/EMAIL_LOGIN_TEST.md b/demo/EMAIL_LOGIN_TEST.md new file mode 100644 index 0000000..6649f04 --- /dev/null +++ b/demo/EMAIL_LOGIN_TEST.md @@ -0,0 +1,216 @@ +# 📧 邮箱验证码登录功能测试指南 + +## 🎯 功能概述 + +已实现完整的邮箱验证码登录功能,包括: +- ✅ 前端登录界面(支持手机/邮箱切换) +- ✅ 后端API接口(验证码发送/验证/登录) +- ✅ 本地模拟测试(无需真实邮件服务) +- ✅ 开发环境友好(验证码在控制台显示) + +## 🚀 快速测试 + +### 方法1:使用测试页面(推荐) + +1. **打开测试页面**: + ``` + 浏览器打开:demo/test-email-login.html + ``` + +2. **测试步骤**: + - 点击"发送验证码"按钮 + - 查看控制台输出的模拟邮件内容 + - 使用验证码 `123456` 进行登录测试 + +### 方法2:使用前端应用 + +1. **启动前端服务**: + ```bash + cd demo/frontend + npm run dev + ``` + +2. **访问登录页面**: + ``` + http://test.yourdomain.com:5173/login + ``` + +3. **测试邮箱登录**: + - 点击"邮箱登录"标签 + - 输入邮箱地址(如:test@example.com) + - 点击"获取验证码" + - 查看控制台输出的验证码 + - 输入验证码进行登录 + +## 🔧 开发环境测试 + +### 模拟邮件发送功能 + +```javascript +// 邮件发送函数 +async function sendVerificationEmail(email, code) { + if (process.env.NODE_ENV === 'development') { + // 开发环境:在控制台显示邮件内容 + console.log(`📨 模拟发送邮件到: ${email}`); + console.log(`📝 邮件内容: 您的验证码是 ${code},有效期5分钟`); + console.log(`📮 发信地址: dev-noreply@local.yourdomain.com`); + return true; + } else { + // 生产环境:调用腾讯云SES + // ... 腾讯云API调用 + } +} +``` + +### 控制台输出示例 + +``` +📨 模拟发送邮件到: test@example.com +📝 邮件内容: 您的验证码是 123456,有效期5分钟 +📮 发信地址: dev-noreply@local.yourdomain.com +``` + +## 📋 API接口测试 + +### 1. 发送验证码 + +```bash +curl -X POST http://api.yourdomain.com:8080/api/verification/email/send \ + -H "Content-Type: application/json" \ + -d '{"email": "test@example.com"}' +``` + +**响应**: +```json +{ + "success": true, + "message": "验证码发送成功" +} +``` + +### 2. 验证码登录 + +```bash +curl -X POST http://api.yourdomain.com:8080/api/auth/login/email \ + -H "Content-Type: application/json" \ + -d '{"email": "test@example.com", "code": "123456"}' +``` + +**响应**: +```json +{ + "success": true, + "message": "登录成功", + "data": { + "user": { + "id": 1, + "username": "test", + "email": "test@example.com", + "role": "ROLE_USER" + }, + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." + } +} +``` + +## 🎨 前端界面功能 + +### 登录方式切换 +- **手机登录**:传统的手机号验证码登录 +- **邮箱登录**:新的邮箱验证码登录 + +### 邮箱登录流程 +1. 选择"邮箱登录"标签 +2. 输入邮箱地址 +3. 点击"获取验证码" +4. 查看控制台获取验证码 +5. 输入验证码并登录 + +### 界面特性 +- ✅ 响应式设计 +- ✅ 表单验证 +- ✅ 倒计时功能 +- ✅ 错误提示 +- ✅ 开发模式友好 + +## 🔍 故障排除 + +### 常见问题 + +#### 1. 验证码发送失败 +- **检查**:后端服务是否启动 +- **解决**:启动后端服务或使用开发模式 + +#### 2. 登录失败 +- **检查**:验证码是否正确 +- **解决**:使用控制台显示的验证码 + +#### 3. 网络错误 +- **检查**:API地址是否正确 +- **解决**:确认域名配置或使用localhost + +### 开发模式特性 + +1. **模拟邮件发送**: + - 验证码在控制台显示 + - 无需真实邮件服务 + - 适合开发和测试 + +2. **模拟登录成功**: + - 网络错误时自动降级 + - 开发环境友好 + - 不影响功能测试 + +## 📝 测试用例 + +### 测试用例1:正常流程 +1. 输入邮箱:`test@example.com` +2. 点击"获取验证码" +3. 查看控制台验证码:`123456` +4. 输入验证码登录 +5. 预期:登录成功 + +### 测试用例2:错误处理 +1. 输入无效邮箱:`invalid-email` +2. 点击"获取验证码" +3. 预期:显示"请输入正确的邮箱地址" + +### 测试用例3:验证码错误 +1. 输入正确邮箱 +2. 获取验证码 +3. 输入错误验证码:`000000` +4. 预期:显示"验证码错误或已过期" + +## 🚀 生产环境部署 + +### 配置腾讯云SES +1. 修改 `application-tencent.properties` +2. 设置 `spring.profiles.active=tencent` +3. 配置真实的API密钥和发件人信息 + +### 环境变量配置 +```bash +export TENCENT_SECRET_ID=your-secret-id +export TENCENT_SECRET_KEY=your-secret-key +export SES_FROM_EMAIL=noreply@yourdomain.com +``` + +## 📊 功能状态 + +- ✅ 前端界面:完成 +- ✅ 后端API:完成 +- ✅ 本地测试:完成 +- ✅ 开发模式:完成 +- ⏳ 腾讯云集成:可选 +- ⏳ 生产部署:待配置 + +## 🎉 总结 + +邮箱验证码登录功能已完全实现,支持: +- 完整的用户界面 +- 后端API接口 +- 本地模拟测试 +- 开发环境友好 +- 生产环境就绪 + +现在可以开始测试邮箱验证码登录功能了! diff --git a/demo/NGROK_CONFIG.md b/demo/NGROK_CONFIG.md new file mode 100644 index 0000000..41a1f11 --- /dev/null +++ b/demo/NGROK_CONFIG.md @@ -0,0 +1,93 @@ +# 内网穿透配置完成 + +## ✅ **已完成的配置修改** + +### 🎨 **前端配置 (vite.config.js)** +```javascript +server: { + port: 5173, + host: '0.0.0.0', // 允许外部访问 + allowedHosts: true, // 允许所有主机访问 + proxy: { + '/api': { + target: 'http://localhost:8080', + changeOrigin: true, + secure: false, + // ... 其他配置 + } + } +} +``` + +### 🔧 **后端配置 (SecurityConfig.java)** +```java +// 允许前端开发服务器和ngrok域名 +configuration.setAllowedOrigins(Arrays.asList( + "http://localhost:3000", + "http://127.0.0.1:3000", + "http://localhost:5173", + "http://127.0.0.1:5173", + "https://*.ngrok.io", + "https://*.ngrok-free.app" +)); +configuration.setAllowedOriginPatterns(Arrays.asList( + "https://*.ngrok.io", + "https://*.ngrok-free.app" +)); +``` + +## 🚀 **使用步骤** + +### 1️⃣ **启动ngrok** +```bash +# 穿透前端端口 +ngrok http 5173 + +# 穿透后端端口 +ngrok http 8080 +``` + +### 2️⃣ **获取ngrok地址** +ngrok会显示类似: +``` +Forwarding https://abc123.ngrok.io -> http://localhost:5173 +Forwarding https://def456.ngrok.io -> http://localhost:8080 +``` + +### 3️⃣ **修改前端API配置** +需要将前端代码中的API地址改为ngrok地址: + +**修改 `demo/frontend/src/api/request.js`**: +```javascript +baseURL: 'https://你的后端ngrok地址.ngrok.io/api' +``` + +**修改 `demo/frontend/src/views/Login.vue`**: +- 第151行:`'https://你的后端ngrok地址.ngrok.io/api/verification/email/send'` +- 第223行:`'https://你的后端ngrok地址.ngrok.io/api/auth/login/email'` + +### 4️⃣ **测试访问** +- 前端:`https://abc123.ngrok.io` +- 后端API:`https://def456.ngrok.io/api` + +## 🔒 **安全说明** + +- `allowedHosts: true` 允许所有主机访问(仅开发环境) +- CORS配置支持ngrok域名模式匹配 +- 生产环境建议限制具体的域名 + +## 📝 **注意事项** + +1. **ngrok免费版限制**: + - 每次重启ngrok,域名会变化 + - 需要重新配置前端API地址 + +2. **HTTPS证书**: + - ngrok提供HTTPS,但证书可能不被信任 + - 浏览器可能显示安全警告 + +3. **网络延迟**: + - 通过ngrok访问会有额外延迟 + - 建议在本地测试完成后再使用ngrok + +现在您可以安全地使用ngrok进行内网穿透测试了! diff --git a/demo/SES_WEBHOOK_CONFIG.md b/demo/SES_WEBHOOK_CONFIG.md new file mode 100644 index 0000000..39670e9 --- /dev/null +++ b/demo/SES_WEBHOOK_CONFIG.md @@ -0,0 +1,138 @@ +# 腾讯云SES Webhook配置指南 + +## 📧 **SES Webhook接口说明** + +系统已创建了完整的SES webhook接口来接收腾讯云SES服务的推送数据。 + +### 🔗 **Webhook接口列表** + +| 接口路径 | 功能描述 | 触发时机 | +|---------|---------|---------| +| `POST /api/email/send-status` | 邮件发送状态回调 | 邮件发送成功/失败时 | +| `POST /api/email/delivery-status` | 邮件投递状态回调 | 邮件投递到收件人邮箱时 | +| `POST /api/email/bounce` | 邮件退信回调 | 邮件无法投递时 | +| `POST /api/email/complaint` | 邮件投诉回调 | 收件人投诉为垃圾邮件时 | +| `POST /api/email/open` | 邮件打开事件回调 | 收件人打开邮件时 | +| `POST /api/email/click` | 邮件点击事件回调 | 收件人点击邮件链接时 | +| `POST /api/email/configuration-set` | 配置集事件回调 | 配置集状态变化时 | + +### 🌐 **ngrok配置示例** + +#### 1. 启动ngrok穿透后端端口8080 +```bash +ngrok http 8080 +``` + +#### 2. 获取ngrok公网地址 +ngrok会显示类似: +``` +Forwarding https://abc123.ngrok.io -> http://localhost:8080 +``` + +#### 3. 在腾讯云SES控制台配置Webhook +- 登录腾讯云SES控制台 +- 进入"配置集"管理 +- 添加事件发布目标 +- 配置webhook URL: + ``` + https://abc123.ngrok.io/api/email/send-status + https://abc123.ngrok.io/api/email/delivery-status + https://abc123.ngrok.io/api/email/bounce + https://abc123.ngrok.io/api/email/complaint + https://abc123.ngrok.io/api/email/open + https://abc123.ngrok.io/api/email/click + https://abc123.ngrok.io/api/email/configuration-set + ``` + +### 📊 **接收的数据格式** + +#### 邮件发送状态回调 +```json +{ + "MessageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "Status": "Send", + "Email": "user@example.com", + "Timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +#### 邮件退信回调 +```json +{ + "MessageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "Email": "user@example.com", + "BounceType": "Permanent", + "BounceSubType": "General", + "Timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +#### 邮件投诉回调 +```json +{ + "MessageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "Email": "user@example.com", + "ComplaintType": "abuse", + "Timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +### 🔧 **系统处理逻辑** + +#### 发送状态处理 +- **Send**: 记录发送成功 +- **Reject**: 记录发送被拒绝 +- **Bounce**: 记录退信情况 + +#### 退信处理 +- **硬退信**: 考虑从邮件列表移除 +- **软退信**: 稍后重试发送 + +#### 投诉处理 +- 记录投诉信息 +- 检查邮件内容合规性 +- 考虑移除问题邮箱 + +### 📝 **日志记录** + +所有webhook事件都会记录到系统日志中,包括: +- 事件类型 +- 邮件地址 +- 时间戳 +- 相关参数 + +### 🛡️ **安全配置** + +- 所有webhook接口已配置为允许匿名访问 +- 建议在生产环境中添加签名验证 +- 可以添加IP白名单限制 + +### 🚀 **测试方法** + +#### 1. 使用curl测试 +```bash +curl -X POST https://your-ngrok-url.ngrok.io/api/email/send-status \ + -H "Content-Type: application/json" \ + -d '{ + "MessageId": "test-123", + "Status": "Send", + "Email": "test@example.com", + "Timestamp": "2024-01-01T12:00:00.000Z" + }' +``` + +#### 2. 查看日志 +检查应用日志,确认webhook事件被正确处理: +``` +INFO - 收到邮件发送状态回调: {MessageId=test-123, Status=Send, Email=test@example.com} +INFO - 邮件发送状态 - MessageId: test-123, Status: Send, Email: test@example.com +``` + +### 📋 **后续扩展** + +可以根据业务需求扩展webhook处理逻辑: +1. 添加数据库存储 +2. 实现邮件发送统计 +3. 添加用户行为分析 +4. 实现自动重试机制 +5. 添加邮件模板优化建议 diff --git a/demo/TENCENT_SES_CONFIG.md b/demo/TENCENT_SES_CONFIG.md new file mode 100644 index 0000000..1edc95c --- /dev/null +++ b/demo/TENCENT_SES_CONFIG.md @@ -0,0 +1,191 @@ +# 腾讯云邮件推送服务(SES)配置指南 + +## 🎯 配置目标 + +配置腾讯云SES服务,实现真实的邮件验证码发送功能。 + +## 📋 详细配置步骤 + +### 1. 开通腾讯云SES服务 + +#### 1.1 登录腾讯云控制台 +- 访问:https://console.cloud.tencent.com/ +- 使用您的腾讯云账号登录 + +#### 1.2 开通邮件推送服务 +1. 在控制台搜索"邮件推送"或"SES" +2. 进入邮件推送控制台 +3. 点击"立即开通" +4. 完成实名认证(如需要) + +### 2. 获取API密钥 + +#### 2.1 创建API密钥 +1. 控制台 → 访问管理 → API密钥管理 +2. 点击"新建密钥" +3. 记录以下信息: + - **SecretId**:如 `AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` + - **SecretKey**:如 `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` + +### 3. 配置发件人邮箱 + +#### 3.1 添加发件人 +1. 邮件推送控制台 → 发件人管理 +2. 点击"添加发件人" +3. 填写信息: + - **发件人邮箱**:如 `noreply@yourdomain.com` + - **发件人名称**:如 `AIGC Demo` +4. 点击"确定" + +#### 3.2 验证发件人 +1. 系统会向您的邮箱发送验证邮件 +2. 点击邮件中的验证链接 +3. 验证成功后,发件人状态变为"已验证" + +### 4. 修改配置文件 + +编辑 `src/main/resources/application-tencent.properties`: + +```properties +# 腾讯云配置 +tencent.cloud.secret-id=AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +tencent.cloud.secret-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + +# 邮件推送服务配置 +tencent.cloud.ses.region=ap-beijing +tencent.cloud.ses.from-email=noreply@yourdomain.com +tencent.cloud.ses.from-name=AIGC Demo +tencent.cloud.ses.template-id=your-email-template-id +``` + +### 5. 配置邮件模板(可选) + +#### 5.1 创建邮件模板 +1. 邮件推送控制台 → 邮件模板 +2. 点击"创建模板" +3. 选择"验证码模板" +4. 填写模板内容: + +**模板名称**:验证码邮件 +**模板内容**: +```html + + + + + 验证码 + + +
+

+ 验证码 +

+

您好!

+

您的验证码是:{{code}}

+

请在5分钟内输入,如非本人操作,请忽略此邮件。

+
+

+ 此邮件由系统自动发送,请勿回复。 +

+
+ + +``` + +#### 5.2 获取模板ID +- 模板创建成功后,记录模板ID +- 更新配置文件中的 `tencent.cloud.ses.template-id` + +### 6. 启用腾讯云配置 + +#### 6.1 修改主配置文件 +编辑 `src/main/resources/application.properties`: + +```properties +# 启用腾讯云配置 +spring.profiles.active=tencent +``` + +#### 6.2 修改验证码服务 +取消注释 `VerificationCodeService.java` 中的腾讯云相关代码: + +```java +@Autowired +private TencentCloudConfig tencentCloudConfig; +``` + +### 7. 测试配置 + +#### 7.1 启动应用 +```bash +mvn spring-boot:run +``` + +#### 7.2 测试发送验证码 +```bash +curl -X POST http://api.yourdomain.com:8080/api/verification/email/send \ + -H "Content-Type: application/json" \ + -d '{"email": "your-test-email@example.com"}' +``` + +#### 7.3 检查邮件 +- 查看您的邮箱是否收到验证码邮件 +- 检查应用日志中的发送状态 + +## 🔧 配置参数说明 + +| 参数 | 说明 | 示例值 | +|------|------|--------| +| `secret-id` | 腾讯云API密钥ID | `AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` | +| `secret-key` | 腾讯云API密钥 | `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` | +| `ses.region` | 服务地域 | `ap-beijing` | +| `ses.from-email` | 发件人邮箱 | `noreply@yourdomain.com` | +| `ses.from-name` | 发件人名称 | `AIGC Demo` | +| `ses.template-id` | 邮件模板ID | `123456` | + +## 🚨 注意事项 + +### 安全提醒 +1. **保护API密钥**:不要将SecretId和SecretKey提交到代码仓库 +2. **使用环境变量**:生产环境建议使用环境变量存储敏感信息 +3. **限制权限**:为API密钥设置最小权限 + +### 费用说明 +1. **免费额度**:腾讯云SES通常有免费额度 +2. **计费方式**:按发送量计费 +3. **成本控制**:设置发送频率限制 + +### 限制说明 +1. **发送频率**:同一邮箱60秒内只能发送一次 +2. **验证码有效期**:5分钟 +3. **每日限额**:根据您的套餐设置 + +## 🔍 故障排除 + +### 常见问题 + +#### 1. 邮件发送失败 +- 检查API密钥是否正确 +- 检查发件人是否已验证 +- 检查网络连接 + +#### 2. 验证码收不到 +- 检查垃圾邮件文件夹 +- 检查邮箱地址是否正确 +- 检查发送频率限制 + +#### 3. 配置不生效 +- 检查配置文件路径 +- 检查profile配置 +- 重启应用 + +### 日志查看 +```bash +# 查看应用日志 +tail -f logs/application.log | grep "验证码" +``` + +## 📞 技术支持 + +- 腾讯云SES文档:https://cloud.tencent.com/document/product/1288 +- 腾讯云技术支持:https://cloud.tencent.com/about/connect diff --git a/demo/TENCENT_SES_WEBHOOK_DESIGN.md b/demo/TENCENT_SES_WEBHOOK_DESIGN.md new file mode 100644 index 0000000..99a9ffa --- /dev/null +++ b/demo/TENCENT_SES_WEBHOOK_DESIGN.md @@ -0,0 +1,247 @@ +# 腾讯云SES邮件验证回调路径设计 + +## 📧 **回调接口设计** + +### 🔗 **回调地址** +``` +POST /api/tencent/ses/webhook +``` + +### 🌐 **完整URL示例** +``` +https://your-domain.com/api/tencent/ses/webhook +``` + +## 🔧 **腾讯云控制台配置** + +### 1️⃣ **配置步骤** +1. 登录腾讯云邮件推送控制台 +2. 导航至"邮件配置" > "回调配置" > "回调地址配置" +3. 选择回调级别: + - **账户级回调**:对该账户下所有发信地址生效 + - **发信地址级回调**:仅对指定发信地址生效(优先级更高) +4. 输入回调地址:`https://your-domain.com/api/tencent/ses/webhook` +5. 保存配置 + +### 2️⃣ **端口要求** +- 仅支持端口:**8080**, **8081**, **8082** +- 必须使用HTTPS协议 +- 确保回调地址可公网访问 + +## 📊 **支持的事件类型** + +| 事件类型 | 描述 | 触发时机 | +|---------|------|---------| +| `delivery` | 递送成功 | 邮件成功送达收件人邮箱 | +| `reject` | 腾讯云拒信 | 由于腾讯云策略原因被拒绝发送 | +| `bounce` | ESP退信 | 邮件被收件人邮箱服务提供商退回 | +| `open` | 用户打开邮件 | 收件人打开了邮件 | +| `click` | 点击链接 | 收件人点击了邮件中的链接 | +| `unsubscribe` | 退订 | 收件人选择退订邮件 | + +## 📝 **回调数据格式** + +### 基础数据结构 +```json +{ + "eventType": "delivery", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +### 递送成功事件 +```json +{ + "eventType": "delivery", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +### 拒信事件 +```json +{ + "eventType": "reject", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "reason": "Content policy violation", + "timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +### 退信事件 +```json +{ + "eventType": "bounce", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "bounceType": "Permanent", + "bounceSubType": "General", + "timestamp": "2024-01-01T12:00:00.000Z" +} +``` + +### 打开事件 +```json +{ + "eventType": "open", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "timestamp": "2024-01-01T12:00:00.000Z", + "userAgent": "Mozilla/5.0...", + "ipAddress": "192.168.1.1" +} +``` + +### 点击事件 +```json +{ + "eventType": "click", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "timestamp": "2024-01-01T12:00:00.000Z", + "link": "https://example.com/click", + "userAgent": "Mozilla/5.0...", + "ipAddress": "192.168.1.1" +} +``` + +### 退订事件 +```json +{ + "eventType": "unsubscribe", + "messageId": "0000014a-f4d4-4f4f-8f4f-4f4f4f4f4f4f-000000", + "email": "user@example.com", + "timestamp": "2024-01-01T12:00:00.000Z", + "unsubscribeType": "one-click" +} +``` + +## 🔒 **安全验证** + +### 请求头验证 +```http +X-Tencent-Token: your-token +X-Tencent-Timestamp: 1640995200 +X-Tencent-Signature: calculated-signature +``` + +### 签名验证流程 +1. 获取请求头中的Token、时间戳、签名 +2. 验证时间戳(防止重放攻击) +3. 使用预共享密钥计算签名 +4. 对比签名是否一致 + +## 🚀 **ngrok测试配置** + +### 1️⃣ **启动ngrok** +```bash +# 穿透后端端口8080 +ngrok http 8080 +``` + +### 2️⃣ **获取公网地址** +``` +Forwarding https://abc123.ngrok.io -> http://localhost:8080 +``` + +### 3️⃣ **配置回调地址** +``` +https://abc123.ngrok.io/api/tencent/ses/webhook +``` + +### 4️⃣ **测试回调** +```bash +curl -X POST https://abc123.ngrok.io/api/tencent/ses/webhook \ + -H "Content-Type: application/json" \ + -H "X-Tencent-Token: test-token" \ + -H "X-Tencent-Timestamp: 1640995200" \ + -H "X-Tencent-Signature: test-signature" \ + -d '{ + "eventType": "delivery", + "messageId": "test-123", + "email": "test@example.com", + "timestamp": "2024-01-01T12:00:00.000Z" + }' +``` + +## 📋 **业务处理逻辑** + +### 递送成功处理 +- 更新邮件状态为"已送达" +- 记录递送统计 +- 更新用户活跃度 +- 触发后续营销流程 + +### 拒信处理 +- 记录拒信原因 +- 检查邮件内容合规性 +- 更新发送策略 +- 通知管理员 + +### 退信处理 +- 区分硬退信和软退信 +- 硬退信:从邮件列表移除 +- 软退信:标记重试 +- 更新邮箱有效性状态 + +### 打开/点击处理 +- 记录用户行为统计 +- 分析用户兴趣 +- 更新用户画像 +- 触发个性化推荐 + +### 退订处理 +- 立即停止发送邮件 +- 更新用户订阅状态 +- 记录退订原因 +- 发送退订确认 + +## ⚠️ **注意事项** + +1. **重试机制**:腾讯云SES会重试失败的回调,最多3次 +2. **响应要求**:必须返回HTTP 200状态码 +3. **处理时间**:建议在5秒内完成处理 +4. **幂等性**:确保重复回调不会产生副作用 +5. **日志记录**:详细记录所有回调事件 +6. **监控告警**:设置回调失败告警机制 + +## 🔧 **扩展功能** + +### 数据库设计 +```sql +-- 邮件事件表 +CREATE TABLE email_events ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + message_id VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL, + event_type VARCHAR(50) NOT NULL, + event_data JSON, + timestamp DATETIME NOT NULL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP +); + +-- 邮件统计表 +CREATE TABLE email_statistics ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + email VARCHAR(255) NOT NULL, + total_sent INT DEFAULT 0, + total_delivered INT DEFAULT 0, + total_opened INT DEFAULT 0, + total_clicked INT DEFAULT 0, + total_bounced INT DEFAULT 0, + last_activity DATETIME, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +### 监控指标 +- 回调成功率 +- 事件处理延迟 +- 各事件类型分布 +- 错误率统计 + +现在您有了一个完整的腾讯云SES邮件验证回调路径设计! diff --git a/demo/frontend/public/images/backgrounds/login.png b/demo/frontend/public/images/backgrounds/login.png index 5cd17b2..6988b90 100644 Binary files a/demo/frontend/public/images/backgrounds/login.png and b/demo/frontend/public/images/backgrounds/login.png differ diff --git a/demo/frontend/src/api/request.js b/demo/frontend/src/api/request.js index 402136c..38dfc99 100644 --- a/demo/frontend/src/api/request.js +++ b/demo/frontend/src/api/request.js @@ -4,7 +4,7 @@ import router from '@/router' // 创建axios实例 const api = axios.create({ - baseURL: 'http://api.yourdomain.com:8080/api', + baseURL: 'http://localhost:8080/api', timeout: 10000, withCredentials: true, headers: { diff --git a/demo/frontend/src/router/index.js b/demo/frontend/src/router/index.js index 10317b1..689941b 100644 --- a/demo/frontend/src/router/index.js +++ b/demo/frontend/src/router/index.js @@ -82,7 +82,7 @@ const routes = [ }, { path: '/', - redirect: '/profile' // 重定向到个人主页 + redirect: '/welcome' // 重定向到欢迎页面 }, { path: '/welcome', diff --git a/demo/frontend/src/views/Login.vue b/demo/frontend/src/views/Login.vue index 1106814..35a7b31 100644 --- a/demo/frontend/src/views/Login.vue +++ b/demo/frontend/src/views/Login.vue @@ -16,37 +16,42 @@

智创无限,灵感变现

+ +
+

邮箱验证码登录

+
+
- -
-
- +86 - + + - - -
- - - {{ countdown > 0 ? `${countdown}s` : '获取验证码' }} -
@@ -64,21 +69,15 @@ 登录即表示您同意遵守用户协议和隐私政策

- +
- 测试账号 + 测试邮箱