taoya7-server-emails
v1.0.0
Published
基于 React Email 的现代化邮件模板库,支持多种邮件发送场景,可自定义主题色
Downloads
84
Maintainers
Readme
📧 Better Auth Emails
一个基于 React Email 的现代化邮件模板库,专门为认证和通知场景设计。提供了丰富的邮件模板和组件,支持多种邮件发送场景。
✨ 特性
- 🎨 现代化设计 - 基于统一的设计系统,确保视觉一致性
- 📱 响应式布局 - 完美适配各种设备和邮件客户端
- 🧩 组件化架构 - 可复用的组件,易于定制和扩展
- 🎯 多种模板 - 涵盖常见的邮件发送场景
- 🔧 TypeScript + Zod - 完整的类型定义和运行时验证
- 🚀 开箱即用 - 提供默认数据,可直接预览效果
- 📦 多种传输方式 - 支持 Resend、SMTP、开发模式
📬 邮件模板
提供以下开箱即用的邮件模板:
- 🔑 Magic Link - 魔法链接登录
- 🔐 Email OTP - 邮箱验证码
- 🔄 Reset Password - 重置密码
- 👋 Welcome - 欢迎新用户
- 🔔 Login Notify - 登录通知
- 🔧 API Key Created - API密钥创建通知
- 📦 Order Confirmation - 订单确认
- 📢 Notification - 通用通知
📦 安装
pnpm add @taoya7/server-emails🚀 快速开始
基础使用
import { EmailClient } from '@taoya7/server-emails'
// 创建邮件客户端
const client = new EmailClient({
transport: {
type: 'resend',
apiKey: process.env.RESEND_API_KEY
},
imagesBaseUrl: 'https://yourdomain.com',
from: '[email protected]',
replyTo: '[email protected]',
emailConfig: {
appName: '你的应用名称',
company: {
name: '你的公司',
website: 'https://yourdomain.com',
supportEmail: '[email protected]'
}
}
})
### 传输方式配置
#### 1. Resend
```typescript
const client = new EmailClient({
transport: {
type: 'resend',
apiKey: 'your-resend-api-key'
},
// ... 其他配置
})2. SMTP
const client = new EmailClient({
transport: {
type: 'smtp',
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: '[email protected]',
pass: 'your-password'
}
},
// ... 其他配置
})3. 开发模式(不实际发送)
const client = new EmailClient({
transport: { type: undefined }, // 或者不传 transport
// ... 其他配置
})📮 联系方式
- Email: [email protected]
- Website: https://taoya.art
