Aliyun Mail Skill
This skill enables sending emails through Aliyun enterprise email service with advanced features including Markdown conversion, HTML styling, file attachments, and syntax highlighting for code blocks.
Features
- - Aliyun Enterprise Email Support: Optimized for Aliyun's SMTP service (smtp.mxhichina.com)
- Multiple Content Types: Send plain text, Markdown, or HTML emails
- Markdown with Syntax Highlighting: Automatic syntax highlighting for code blocks in Markdown
- File Attachments: Include one or more files as attachments
- Configuration-based: Uses a secure configuration file for SMTP credentials
- Error Handling: Includes retry logic and detailed error reporting
Prerequisites
- - SMTP Configuration File: Create
aliyun-mail-config.json in your OpenClaw config directory (/root/.openclaw/)
Example configuration file:
CODEBLOCK0
Ensure the configuration file has secure permissions:
CODEBLOCK1
Usage
Basic Text Email
CODEBLOCK2
Markdown Email with Syntax Highlighting
aliyun-mail send \
--to "recipient@example.com" \
--subject "Code Report" \
--body "**Check out this Python code:**\n\n
python\nprint('Hello World')\n``
" \
--markdown
CODEBLOCK4 bash
aliyun-mail send \
--to "recipient@example.com" \
--subject "Weekly Report" \
--body "<h1>Weekly Report</h1><p>See attached file.</p>" \
--html \
--attachments "/path/to/report.pdf"
CODEBLOCK5 bash
aliyun-mail send \
--to "recipient@example.com" \
--subject "Report from File" \
--body-file "/path/to/report.md" \
--markdown \
--attachments "/path/to/data.csv"
`
## Command Line Options
- --to
: Recipient email address (required)
- --subject
: Email subject (required)
- --body
: Email body content (required if --body-file not provided)
- --body-file
: Path to file containing email body
- --html
: Send as HTML email (default: plain text)
- --markdown
: Send as Markdown email with syntax highlighting
- --attachments`: Space-separated list of file paths to attach
Error Handling
The tool includes robust error handling with up to 3 retry attempts on failure. Network issues, authentication errors, and invalid email addresses are reported with detailed error messages.
Security Notes
- - Always use app-specific passwords rather than your main email password
- Keep the configuration file secure with proper file permissions
- Never commit configuration files to version control
Future Enhancements
- - Support for CC/BCC recipients
- Email templates system
- Scheduled email sending
- Rich text editor integration
阿里云邮件技能
该技能支持通过阿里云企业邮箱服务发送邮件,具备Markdown转换、HTML样式、文件附件及代码块语法高亮等高级功能。
功能特性
- - 阿里云企业邮箱支持:针对阿里云SMTP服务(smtp.mxhichina.com)优化
- 多种内容类型:支持发送纯文本、Markdown或HTML格式邮件
- 带语法高亮的Markdown:自动为Markdown中的代码块添加语法高亮
- 文件附件:支持包含一个或多个文件作为附件
- 基于配置:使用安全配置文件存储SMTP凭据
- 错误处理:包含重试逻辑和详细错误报告
前置条件
- - SMTP配置文件:在OpenClaw配置目录(/root/.openclaw/)中创建aliyun-mail-config.json
示例配置文件:
json
{
server: smtp.mxhichina.com,
port: 465,
username: your-email@yourdomain.com,
password: your-app-password,
emailFrom: your-email@yourdomain.com,
useTLS: true
}
确保配置文件具有安全权限:
bash
chmod 600 /root/.openclaw/aliyun-mail-config.json
使用方法
基本文本邮件
bash
aliyun-mail send --to recipient@example.com --subject Hello --body 这是一封纯文本邮件
带语法高亮的Markdown邮件
bash
aliyun-mail send \
--to recipient@example.com \
--subject 代码报告 \
--body
查看这段Python代码:\n\npython\nprint(Hello World)\n \
--markdown
带附件的HTML邮件
bash
aliyun-mail send \
--to recipient@example.com \
--subject 周报 \
--body
周报
请查看附件。
\
--html \
--attachments /path/to/report.pdf
从文件读取正文
bash
aliyun-mail send \
--to recipient@example.com \
--subject 来自文件的报告 \
--body-file /path/to/report.md \
--markdown \
--attachments /path/to/data.csv
命令行选项
- - --to:收件人邮箱地址(必填)
- --subject:邮件主题(必填)
- --body:邮件正文内容(未提供--body-file时必填)
- --body-file:包含邮件正文的文件路径
- --html:以HTML格式发送邮件(默认:纯文本)
- --markdown:以带语法高亮的Markdown格式发送邮件
- --attachments:以空格分隔的附件文件路径列表
错误处理
该工具包含强大的错误处理机制,失败时最多重试3次。网络问题、认证错误和无效邮箱地址都会附带详细错误信息进行报告。
安全注意事项
- - 始终使用应用专用密码而非主邮箱密码
- 通过适当的文件权限确保配置文件安全
- 切勿将配置文件提交到版本控制
未来增强
- - 支持抄送/密送收件人
- 邮件模板系统
- 定时发送邮件
- 富文本编辑器集成