Send Email
Send emails via the Python script. SMTP settings are injected by OpenClaw at runtime when the script runs (from ~/.openclaw/openclaw.json → skills.entries.send-email.env). Do not read any config file (e.g. ~/.openclaw/openclaw.json or workspace/openclaw.json) — that would expose credentials in tool output. Just run the script; env is injected automatically. Do not use ~/.msmtprc.
Configuration
Configure in ~/.openclaw/openclaw.json:
CODEBLOCK0
| Variable | Description |
|---|
| EMAILSMTPSERVER | SMTP server, e.g. smtp.163.com, smtp.gmail.com |
| EMAILSMTPPORT |
Port, 465 (SSL) or 587 (TLS) |
| EMAIL_SENDER | Sender email address |
| EMAIL
SMTPPASSWORD | Authorization code / app password (163/QQ: auth code; Gmail: App Password) |
Agent instructions
- 1. Credentials: Never read config files. OpenClaw injects
skills.entries.send-email.env when the script runs — do not use the read tool on ~/.openclaw/openclaw.json or workspace/openclaw.json (exposes secrets). If the skill is enabled, assume env is configured; do not ask the user for passwords. Do not use ~/.msmtprc. - Send mail: Run the script under workspace (do not use the path under node_modules):
python3 ~/.openclaw/workspace/skills/send-email/send_email.py "recipient" "Subject" "Body"
- 3. Attachment: INLINECODE8
Usage examples
CODEBLOCK2
SMTP reference
- - 163:
smtp.163.com:465, requires authorization code (not login password) - Gmail:
smtp.gmail.com:587, requires App Password - QQ:
smtp.qq.com:465, requires authorization code
Troubleshooting
- - Authentication failed: Check that
EMAIL_SMTP_PASSWORD is the authorization code or App Password. - Connection failed: Check
EMAIL_SMTP_SERVER and EMAIL_SMTP_PORT.
发送邮件
通过Python脚本发送邮件。SMTP设置由OpenClaw在运行时注入(来自~/.openclaw/openclaw.json → skills.entries.send-email.env)。不要读取任何配置文件(例如~/.openclaw/openclaw.json或workspace/openclaw.json),否则会在工具输出中暴露凭据。只需运行脚本;环境变量会自动注入。不要使用~/.msmtprc。
配置
在~/.openclaw/openclaw.json中配置:
json
skills: {
entries: {
send-email: {
enabled: true,
env: {
EMAILSMTPSERVER: smtp.163.com,
EMAILSMTPPORT: 465,
EMAIL_SENDER: your-email@163.com,
EMAILSMTPPASSWORD: YOURAUTHCODE
}
}
}
}
| 变量 | 描述 |
|---|
| EMAILSMTPSERVER | SMTP服务器,例如smtp.163.com、smtp.gmail.com |
| EMAILSMTPPORT |
端口,465(SSL)或587(TLS) |
| EMAIL_SENDER | 发件人邮箱地址 |
| EMAIL
SMTPPASSWORD | 授权码/应用密码(163/QQ:授权码;Gmail:应用密码) |
代理指令
- 1. 凭据:切勿读取配置文件。OpenClaw在脚本运行时注入skills.entries.send-email.env——不要在~/.openclaw/openclaw.json或workspace/openclaw.json上使用读取工具(会暴露密钥)。如果技能已启用,则假定环境变量已配置;不要向用户询问密码。不要使用~/.msmtprc。
- 发送邮件:在workspace下运行脚本(不要使用node_modules下的路径):
bash
python3 ~/.openclaw/workspace/skills/send-email/send_email.py 收件人 主题 正文
- 3. 附件:python3 ~/.openclaw/workspace/skills/send-email/send_email.py 收件人 主题 正文 /路径/到/文件.pdf
使用示例
bash
python3 ~/.openclaw/workspace/skills/send-email/send_email.py recipient@example.com 主题 正文文本
python3 ~/.openclaw/workspace/skills/send-email/send_email.py recipient@example.com 主题 正文 /路径/到/文件.pdf
SMTP参考
- - 163:smtp.163.com:465,需要授权码(非登录密码)
- Gmail:smtp.gmail.com:587,需要应用密码
- QQ:smtp.qq.com:465,需要授权码
故障排除
- - 认证失败:检查EMAILSMTPPASSWORD是否为授权码或应用密码。
- 连接失败:检查EMAILSMTPSERVER和EMAILSMTPPORT。