junkaixue-gmail-sender
通过 Gmail SMTP 与应用专用密码发送邮件,适用于告警、通知与自动化报告。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~junkaixue-gmail-sendercURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~junkaixue-gmail-sender/file -o junkaixue-gmail-sender.md## 概述(中文)
通过 Gmail SMTP 与应用专用密码发送邮件,适用于告警、通知与自动化报告。
## 技能正文
# Gmail Sender 技能
通过 Gmail SMTP 使用 Google 应用专用密码发送邮件。适用于告警、通知和自动化报告的通用工具。
## 概述
一个通过 Gmail SMTP 发送邮件的简单 CLI 工具。除 Python 标准库外无任何外部依赖。
## 要求
- Python 3.6+
- 已启用应用专用密码的 Gmail 账户
## 设置
1. 为你的 Google 账户启用两步验证:
- 前往 https://myaccount.google.com/security
2. 生成应用专用密码:
- 前往 https://myaccount.google.com/apppasswords
- 选择 "Mail" 作为应用
- 复制这个 16 位密码(不含空格)
3. 设置环境变量:
```bash
export GMAIL_USER="your-email@gmail.com"
export GMAIL_APP_PASSWORD="xxxxxxxxxxxxxxxx"
```
## 安装
将本技能克隆或复制到你的 OpenClaw 技能目录:
```bash
cp -r gmail-sender ~/.openclaw/workspace/skills/
```
或使用 CLI:
```bash
clawhub install gmail-sender
```
## 用法
```bash
# Make executable
chmod +x gmail-send
# Send email
./gmail-send "recipient@example.com" "Subject" "Body text"
```
### 示例
```bash
# Simple notification
./gmail-send "admin@example.com" "Server Alert" "CPU usage at 90%"
# Cron job integration
0 9 * * 1-5 ~/.openclaw/scripts/gmail-send "you@example.com" "Morning Report" "$(date)"
```
## Python 模块用法
```python
import subprocess
# Call from Python
subprocess.run([
'./gmail-send',
'recipient@example.com',
'Subject',
'Body'
], env={'GMAIL_USER': '...', 'GMAIL_APP_PASSWORD': '...'})
```
## 安全注意事项
- 切勿将应用专用密码提交到版本控制
- 使用环境变量,切勿硬编码凭证
- 应用专用密码为 16 个字符(格式:xxxx xxxx xxxx xxxx)
- 如凭证泄露请立即吊销应用专用密码
## 故障排查
**"535 5.7.8 Username and Password not accepted"**
- 确认应用专用密码正确(16 个字符,不含空格)
- 确保你的 Google 账户已启用两步验证
**"Could not connect"**
- 检查防火墙/网络设置
- Gmail 可能会拦截来自未知应用的连接
## 许可证
MIT
## 作者
junkaixue