简介
通过Gmail SMTP发送邮件的轻量工具,无需额外依赖,适合自动化告警和定时报告场景。
原始描述
Send emails via Gmail SMTP using a Python CLI tool with Google App Password for alerts, notifications, and automated reports.
通过你的 Agent 添加
点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。
或者手动安装
包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。
技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。
技能正文
Gmail Sender Skill
Send emails via Gmail SMTP using Google App Password. Generic utility for alerts, notifications, and automated reports.
Overview
A simple CLI tool to send emails through Gmail SMTP. No external dependencies beyond Python standard library.
Requirements
- Python 3.6+
- Gmail account with App Password enabled
Setup
-
Enable 2-Factor Authentication on your Google Account:
-
Generate an App Password:
- Go to https://myaccount.google.com/apppasswords
- Select "Mail" as the app
- Copy the 16-character password (no spaces)
-
Set environment variables:
export GMAIL_USER="your-email@gmail.com"
export GMAIL_APP_PASSWORD="xxxxxxxxxxxxxxxx"
Installation
Clone or copy this skill to your OpenClaw skills directory:
cp -r gmail-sender ~/.openclaw/workspace/skills/
Or use the CLI:
clawhub install gmail-sender
Usage
# Make executable
chmod +x gmail-send
# Send email
./gmail-send "recipient@example.com" "Subject" "Body text"
Examples
# 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 Module Usage
import subprocess
# Call from Python
subprocess.run([
'./gmail-send',
'recipient@example.com',
'Subject',
'Body'
], env={'GMAIL_USER': '...', 'GMAIL_APP_PASSWORD': '...'})
Security Notes
- Never commit App Passwords to version control
- Use environment variables, never hardcode credentials
- App Passwords are 16 characters (format: xxxx xxxx xxxx xxxx)
- Revoke app passwords if compromised
Troubleshooting
"535 5.7.8 Username and Password not accepted"
- Verify App Password is correct (16 chars, no spaces)
- Make sure 2FA is enabled on your Google account
"Could not connect"
- Check firewall/network settings
- Gmail may block connections from unknown apps
License
MIT
Author
junkaixue
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。