Send Email via Gmail
Z3 全文↑ Z2 条目
术-操作 · 术层 skill 全文
本页是 <code>rules/skills/send_email.md</code> 的逐字投影(仅隐私清洗,零改写)。
时点提示:本页是仓内文件 rules/skills/send_email.md 的逐字投影(仅做隐私清洗:仓库根绝对路径→相对路径、家目录→~/;除此零改写)。若源文件后续有修订,以仓内真源为准。
Skill: Send Email via Gmail
This skill allows the AI to send email notifications using a Gmail app-specific password.
When to Use
- 发送报告通知
- 发送任务完成提醒
- 发送重要信息摘要
Prerequisites
- A
.envfile in the root directory containing: GMAIL_USERNAME: The Gmail address used to send the email.GMAIL_APP_PASSWORD: A Gmail app-specific password.GMAIL_RECIPIENTS: The default recipient address (e.g.,<your-email>).
Gmail App Password Setup
- Go to Google Account → Security → 2-Step Verification
- At the bottom: App passwords → Generate a new app password
- Add to
.env: - ```
- GMAIL_USERNAME=your.gmail@gmail.com
- GMAIL_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
- GMAIL_RECIPIENTS=<your-email>
- ```
Usage
Basic usage (plain text)
python3 tools/send_email_to_myself.py "Subject Here" "Body Here"Send to a specific address
python3 tools/send_email_to_myself.py "Subject Here" "Body Here" --to <recipient-email>Send HTML content
python3 tools/send_email_to_myself.py "Subject Here" "<h1>HTML Body</h1>" --htmlSend from file (Markdown auto-converted to HTML)
python3 tools/send_email_to_myself.py "Report Title" "" --file path/to/report.mdSend from file with custom CSS
python3 tools/send_email_to_myself.py "Report Title" "" --file path/to/report.md --css path/to/styles.cssMarkdown to HTML Conversion
当使用 --file 参数指定 .md 文件时,脚本会自动将 Markdown 转换为 HTML:
- 标题(#、##、###)→ h1、h2、h3
- 粗体、斜体
- 链接(url)
- 列表(- 和 1.)
- 表格(| ... |)
- 代码(
code) - 分隔线(---)
内置 GitHub 风格 CSS,可通过 --css 参数自定义。
Example
Send a markdown report as styled HTML email:
python3 tools/send_email_to_myself.py "Weekly AI Report" "" --file contexts/survey_sessions/ai_news_weekly.md