koishi-plugin-email-sender
v1.0.3
Published
Koishi 邮件发送插件,支持多收件人、HTML格式和附件
Maintainers
Readme
koishi-plugin-email-sender
Koishi 邮件发送插件,支持通过命令发送邮件,包括多收件人、HTML格式和附件功能。
功能特点
- 支持发送纯文本或 HTML 格式邮件
- 支持多个收件人(收件人、抄送、密送)
- 支持添加附件
- 支持自定义发件人名称
- 支持邮件主题设置
- 完整的权限控制
安装
# 使用 npm
npm install koishi-plugin-email-sender
# 使用 yarn
yarn add koishi-plugin-email-sender
# 使用 pnpm
pnpm add koishi-plugin-email-sender配置
在 Koishi 配置文件中添加以下配置:
export default {
plugins: {
'email-sender': {
// SMTP 服务器地址
host: 'smtp.example.com',
// SMTP 服务器端口
port: 465,
// 是否使用 SSL/TLS
secure: true,
// 发件人邮箱
auth: {
user: '[email protected]',
pass: 'your-password-or-app-password'
},
// 默认发件人名称(可选)
senderName: 'Koishi Bot',
// 命令名称(可选,默认为 email)
commandName: 'email',
// 权限等级(可选,默认为 3)
authority: 3
}
}
}配置说明
| 配置项 | 类型 | 默认值 | 说明 | |-------|------|-------|------| | host | string | - | SMTP 服务器地址 | | port | number | 465 | SMTP 服务器端口 | | secure | boolean | true | 是否使用 SSL/TLS | | auth.user | string | - | 发件人邮箱地址 | | auth.pass | string | - | 发件人邮箱密码或应用专用密码 | | senderName | string | 'Koishi Bot' | 默认发件人名称 | | commandName | string | 'email' | 命令名称 | | authority | number | 3 | 命令权限等级 |
使用方法
基本用法
发送一封简单的邮件:
email send to:[email protected] subject:"测试邮件" 这是邮件内容高级用法
发送带有 HTML 内容、多个收件人和附件的邮件:
email send to:[email protected],[email protected] cc:[email protected] bcc:[email protected] subject:"HTML测试邮件" --html "<h1>这是一个HTML邮件</h1><p>支持<b>富文本</b>格式</p>" --attach /path/to/file.pdf参数说明
| 参数 | 说明 | |------|------| | to | 收件人邮箱,多个收件人用逗号分隔 | | cc | 抄送邮箱,多个抄送用逗号分隔 | | bcc | 密送邮箱,多个密送用逗号分隔 | | subject | 邮件主题 | | --html | 使用 HTML 格式发送邮件内容 | | --attach | 添加附件,支持本地文件路径 | | --from | 自定义发件人名称(可选) |
注意事项
- 对于 Gmail 等启用了两步验证的邮箱,需要使用应用专用密码而非账户密码
- 确保 SMTP 服务器允许第三方应用访问
- 发送大型附件可能受到邮件服务商的限制
- 命令权限默认为 3 级,可以在配置中调整
示例
发送纯文本邮件
email send to:[email protected] subject:"会议通知" 明天下午3点在会议室A开会,请准时参加。发送 HTML 格式邮件
email send to:[email protected] subject:"HTML邮件测试" --html "<h1>标题</h1><p>这是<b>加粗</b>文本</p><a href='https://koishi.chat'>Koishi官网</a>"发送带附件的邮件
email send to:[email protected] subject:"附件测试" 请查收附件 --attach /home/user/documents/report.pdf发送给多个收件人
email send to:[email protected],[email protected] cc:[email protected] subject:"团队通知" 这是发送给多人的邮件许可证
MIT
