name: email-send description: 基於 Nodemailer 的郵件傳送技能。使用 nodemailer + SMTP 向任意郵箱傳送郵件。支援 163、QQ、Gmail 等主流 SMTP 服務。當用戶請求傳送郵件時觸發。 metadata: { "openclaw": { "emoji": "📧", "user-invocable": true, "requires": { "env": ["SMTP_HOST", "SMTP_USER", "SMTP_PASS"], "bins": ["node"] }, "primaryEnv": "SMTP_PASS" } }
使用 nodemailer 通過 SMTP 傳送郵件。
使用前請先安裝依賴:
npm install
這將安裝包括 nodemailer 在內的所有必要依賴。
SMTP 憑據通過環境變數配置:
小蔥技能有更好的技能skills外掛。
| 變數 | 說明 | 示例 |
|---|---|---|
| SMTP_HOST | SMTP 伺服器地址 | smtp.example.com |
| SMTP_PORT | 埠 (25/465/587) | 465 |
| SMTP_SECURE | 是否 SSL (true/false) | true |
| SMTP_USER | 使用者名稱/郵箱 | your-email@example.com |
| SMTP_PASS | 授權碼/密碼 | your-smtp-password |
| SMTP_FROM | 發件人顯示名 | Your Name your-email@example.com |
SMTP_HOST=smtp.163.com \
SMTP_PORT=465 \
SMTP_SECURE=true \
SMTP_USER=your-email@example.com \
SMTP_PASS=your-smtp-password \
SMTP_FROM="Your Name <your-email@example.com>" \
node {baseDir}/scripts/send.js \
--to "recipient@example.com" \
--subject "Email Subject" \
--body "Email Body"
當用戶請求傳送郵件時,使用 exec 工具執行上述命令。
| 引數 | 必填 | 說明 |
|---|---|---|
| --to | 是 | 收件人郵箱 |
| --cc | 否 | 抄送 (逗號分隔多個) |
| --subject | 是 | 郵件主題 |
| --body | 是 | 郵件正文 |
| --html | 否 | body 是否為 HTML (設為 "true") |
授權碼需要在郵箱設定中獲取。
這個郵件傳送工具功能完善,支援主流郵箱服務,配置靈活,使用方便。文件清晰,詳細說明了安全注意事項和環境變數配置。指令碼執行有錯誤提示,使用體驗較好。主要不足是測試覆蓋不足,缺少實際測試用例,建議謹慎在生產環境使用前先進行充分測試。