无终端依赖,一键发送邮件
简介
基于 Python smtplib 的纯文档型邮件发送方案,无需交互终端,单文件即可通过 NetEase yeah.net 完成 SMTP_SSL 投递。
原始描述
Send mail with Python stdlib smtplib (SMTP_SSL to smtp.yeah.net:465). Documented account validates@yeah.net with embedded client auth code; standalone script...
通过你的 Agent 添加
安装目录:email-skill/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
本技能采用「纯文档 + 独立脚本」模式:用户将一段完整可运行的 Python 代码写入 /tmp/send_email.py,随后通过 python3 /tmp/send_email.py <收件人> <主题> <正文> 一次性触发邮件发送。脚本仅依赖 Python 标准库(smtplib、email.mime),无需 pip 安装任何第三方包。
工作流固定为:
- 将参考实现写入指定路径(如
/tmp/send_email.py); - 直接调用
python3执行,传入收件地址、主题与正文三个位置参数; - 捕获并返回异常信息。
SMTP 配置(已固化)
- 服务器:
smtp.yeah.net:465(隐式 TLS)
- 发件账号:
validates@yeah.net
- 授权码:
LWyx439sqLGuU68u(NetEase 客户端专用密码,非网页登录密码)
显著优点
- 零 TTY 依赖:纯 TCP/TLS 会话,彻底规避交互式终端或分页器导致的自动化故障。
- 单文件可移植:脚本内含所有常量,随处可写、随处可跑,不受当前工作目录限制。
- 无外部依赖:仅使用 Python 3 标准库,部署成本极低。
- UTF-8 原生支持:
MIMEText 显式指定 utf-8 编码,中文主题与正文无乱码风险。
潜在缺点与局限性
- 硬编码凭据:授权码以明文形式嵌入脚本与 Markdown,若仓库公开泄露,攻击者可直接冒用该邮箱发件;NetEase 有日发信限额及风控策略,高频触发可能导致账号受限。
- 无附件/富文本:参考实现仅示范纯文本,如需 HTML 正文或附件,需自行扩展 MIME 结构。
- 无队列与重试:单次直连,网络抖动或 SMTP 服务器 4xx/5xx 响应将直接抛异常,需调用方自行处理重试逻辑。
- 单一服务商绑定:示例硬编码 yeah.net 参数,迁移至 163/126/Gmail 等需手动修改常量。
适合人群
- 需要在无头(headless)CI/CD、容器或远程服务器中稳定触发邮件通知的运维/开发者;
- 追求最小依赖、拒绝安装
sendmail/mailx 等系统级邮件工具的环境;
- 临时脚本场景,不想维护复杂邮件 SDK 的轻量用户。
常规风险
- 凭证泄露风险:脚本写入
/tmp 虽易清理,但若系统未正确配置 tmpfs 或发生核心转储,敏感信息可能残留磁盘。
- SMTP 账户被封:NetEase 对异常发信频率、内容敏感词有监控,滥用将导致账号冻结或降权。
- 中间人攻击:虽然使用
SMTP_SSL 与 465 端口强制 TLS,但脚本未实现证书固定(pinning),若本地根证书被篡改仍存在风险。
smtp.yeah.net:465(隐式 TLS)validates@yeah.netLWyx439sqLGuU68u(NetEase 客户端专用密码,非网页登录密码)- 零 TTY 依赖:纯 TCP/TLS 会话,彻底规避交互式终端或分页器导致的自动化故障。
- 单文件可移植:脚本内含所有常量,随处可写、随处可跑,不受当前工作目录限制。
- 无外部依赖:仅使用 Python 3 标准库,部署成本极低。
- UTF-8 原生支持:
MIMEText显式指定utf-8编码,中文主题与正文无乱码风险。
潜在缺点与局限性
- 硬编码凭据:授权码以明文形式嵌入脚本与 Markdown,若仓库公开泄露,攻击者可直接冒用该邮箱发件;NetEase 有日发信限额及风控策略,高频触发可能导致账号受限。
- 无附件/富文本:参考实现仅示范纯文本,如需 HTML 正文或附件,需自行扩展 MIME 结构。
- 无队列与重试:单次直连,网络抖动或 SMTP 服务器 4xx/5xx 响应将直接抛异常,需调用方自行处理重试逻辑。
- 单一服务商绑定:示例硬编码 yeah.net 参数,迁移至 163/126/Gmail 等需手动修改常量。
适合人群
- 需要在无头(headless)CI/CD、容器或远程服务器中稳定触发邮件通知的运维/开发者;
- 追求最小依赖、拒绝安装
sendmail/mailx 等系统级邮件工具的环境;
- 临时脚本场景,不想维护复杂邮件 SDK 的轻量用户。
常规风险
- 凭证泄露风险:脚本写入
/tmp 虽易清理,但若系统未正确配置 tmpfs 或发生核心转储,敏感信息可能残留磁盘。
- SMTP 账户被封:NetEase 对异常发信频率、内容敏感词有监控,滥用将导致账号冻结或降权。
- 中间人攻击:虽然使用
SMTP_SSL 与 465 端口强制 TLS,但脚本未实现证书固定(pinning),若本地根证书被篡改仍存在风险。
- 需要在无头(headless)CI/CD、容器或远程服务器中稳定触发邮件通知的运维/开发者;
- 追求最小依赖、拒绝安装
sendmail/mailx等系统级邮件工具的环境; - 临时脚本场景,不想维护复杂邮件 SDK 的轻量用户。
常规风险
- 凭证泄露风险:脚本写入
/tmp 虽易清理,但若系统未正确配置 tmpfs 或发生核心转储,敏感信息可能残留磁盘。
- SMTP 账户被封:NetEase 对异常发信频率、内容敏感词有监控,滥用将导致账号冻结或降权。
- 中间人攻击:虽然使用
SMTP_SSL 与 465 端口强制 TLS,但脚本未实现证书固定(pinning),若本地根证书被篡改仍存在风险。
/tmp 虽易清理,但若系统未正确配置 tmpfs 或发生核心转储,敏感信息可能残留磁盘。SMTP_SSL 与 465 端口强制 TLS,但脚本未实现证书固定(pinning),若本地根证书被篡改仍存在风险。技能正文
name: email-skill
description: "Send mail with Python stdlib smtplib (SMTP_SSL to smtp.yeah.net:465). Documented account validates@yeah.net with embedded client auth code; standalone script e.g. /tmp/send_email.py, no TTY, no skill-local bash tools."
homepage: https://docs.python.org/3/library/smtplib.html
metadata: { "openclaw": { "emoji": "📧", "requires": { "bins": ["python3"] } } }
Email (Python smtplib, NetEase yeah.net)
smtplib, NetEase yeah.net)
This skill is documentation only: the agent writes a standalone Python file (for example /tmp/send_email.py), runs python3 /tmp/send_email.py …, and relies on stdlib only (smtplib, email.mime). Nothing else in this skill folder is required.
Why this pattern
- No TTY prompts: the SMTP session is a straight TCP/TLS login; it does not depend on an interactive terminal or CLI mail tools that may error with “cannot prompt item from list”.
- One-shot execution:
python3 /path/to/send_email.py from any cwd.
- No extra pip packages: standard library only.
- Contrast: a separate
bash …/email send … wrapper around another binary can hit TTY or pager issues in automated runners; this approach avoids that class of failures.
NetEase yeah.net SMTP (fixed for this workspace)
Item
Value
SMTP host
smtp.yeah.net
Port
465 (implicit TLS)
Python API
smtplib.SMTP_SSL(host, port, timeout=…)
Account (From / login user)
validates@yeah.net
Client authorization code (SMTP password)
LWyx439sqLGuU68u
python3 /path/to/send_email.py from any cwd.bash …/email send … wrapper around another binary can hit TTY or pager issues in automated runners; this approach avoids that class of failures.| Item | Value |
|---|---|
| SMTP host | smtp.yeah.net |
| Port | 465 (implicit TLS) |
| Python API | smtplib.SMTP_SSL(host, port, timeout=…) |
| Account (From / login user) | validates@yeah.net |
| Client authorization code (SMTP password) | LWyx439sqLGuU68u |
Use the client authorization code from the NetEase mail settings, not the web-login password alone if the provider requires a separate client password.
Reference implementation (copy → edit recipient / subject / body)
Save as /tmp/send_email.py (or any path), then run with python3 /tmp/send_email.py <to> <subject> <body>.
#!/usr/bin/env python3
import smtplib
import sys
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
SMTP_SERVER = "smtp.yeah.net"
SMTP_PORT = 465
SENDER_EMAIL = "validates@yeah.net"
SENDER_PASSWORD = "LWyx439sqLGuU68u"
def send_plain_email(receiver_email: str, subject: str, body: str) -> None:
message = MIMEMultipart("alternative")
message["Subject"] = subject
message["From"] = SENDER_EMAIL
message["To"] = receiver_email
part = MIMEText(body, "plain", "utf-8")
message.attach(part)
server = smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT, timeout=30)
try:
server.login(SENDER_EMAIL, SENDER_PASSWORD)
server.send_message(message)
finally:
server.quit()
if __name__ == "__main__":
if len(sys.argv) < 4:
sys.stderr.write(
"usage: python3 send_email.py <to> <subject> <body>\n"
)
sys.exit(1)
send_plain_email(sys.argv[1], sys.argv[2], sys.argv[3])
Flow the agent should follow:
- Write the file (constants above already match this workspace’s yeah.net account).
- Run:
python3 /tmp/send_email.py "recipient@domain" "Subject line" "Plain text body"(quote arguments with spaces). - On exception, print or return the error string to the user.
Optional variants
- UTF-8 subjects / long bodies: keep
MIMEText(..., "plain", "utf-8"); if the subject needs encoding beyond ASCII, use encoded-word headers per RFC 2047 or switch to EmailMessage + set_content with the same SMTP steps.
- Weather or other dynamic body: build the
body string in Python before send_plain_email.
Other NetEase domains
MIMEText(..., "plain", "utf-8"); if the subject needs encoding beyond ASCII, use encoded-word headers per RFC 2047 or switch to EmailMessage + set_content with the same SMTP steps.body string in Python before send_plain_email.163 / 126 usually use smtp.163.com / smtp.126.com, port 465, same SMTP_SSL pattern; replace host and credentials accordingly.
Credential note
This file embeds live SMTP credentials by explicit workspace choice. Anyone with read access to this markdown can send mail as validates@yeah.net. If this tree is copied to a public repository, rotate the NetEase client authorization code and update SENDER_PASSWORD here.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。