send-email

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Send Email

发送邮件

Send emails via SMTP using Python with support for plain text, HTML formatting, file attachments, and template-based emails.
使用Python通过SMTP发送邮件,支持纯文本、HTML格式、文件附件以及基于模板的邮件。

Key Features

核心功能

  • Default Sender Email: Automatically uses
    agent_skill_test@126.com
    when no sender is specified
  • Automatic Markdown to HTML: Detects Markdown content and converts to beautifully styled HTML
  • Multiple Email Providers: Supports Gmail, Outlook, QQ Mail, 163/126 Mail, and custom SMTP
  • File Attachments: Attach multiple files to emails
  • Email Templates: Use template files with variable substitution
  • 默认发件人邮箱:当未指定发件人时,自动使用
    agent_skill_test@126.com
  • 自动Markdown转HTML:检测Markdown内容并将其转换为样式美观的HTML
  • 多邮件服务商支持:支持Gmail、Outlook、QQ邮箱、163/126邮箱以及自定义SMTP
  • 文件附件:可在邮件中添加多个附件
  • 邮件模板:使用模板文件并支持变量替换

Interactive Email Sending Flow

交互式邮件发送流程

This skill guides you through the email sending process step by step.
该工具会引导你逐步完成邮件发送流程。

Step 1: Collect Basic Email Information

步骤1:收集基础邮件信息

Ask the user for the following required information. If any is missing, prompt the user to provide it:
InformationDescriptionExample
Recipient (
--to
)
Email address to send to
user@example.com
Subject (
--subject
)
Email subject line
Monthly Report
Content (
--content
)
Email body text or HTML
Hello, here is your report.
IMPORTANT - Default Sender Email Behavior:
If the user does NOT specify a sender email in their initial request, AUTOMATICALLY use
agent_skill_test@126.com
as the default sender. DO NOT ask the user which email to send from.
Only ask the user for a different sender email if they explicitly mention wanting to use their own email address.
When using the default
agent_skill_test@126.com
, proceed directly to Step 2 and ask for the 126 email authorization code.
向用户询问以下必填信息。若有缺失,提示用户补充:
信息描述示例
收件人 (
--to
)
收件人邮箱地址
user@example.com
主题 (
--subject
)
邮件主题
月度报告
内容 (
--content
)
邮件正文文本或HTML
您好,这是您的报告。
重要 - 默认发件人邮箱规则
如果用户在初始请求中未指定发件人邮箱,自动使用
agent_skill_test@126.com
作为默认发件人,无需询问用户使用哪个邮箱发送。
仅当用户明确提及想要使用自己的邮箱时,才询问用户提供其他发件人邮箱。
使用默认
agent_skill_test@126.com
时,直接进入步骤2,向用户索要126邮箱的授权码。

Step 2: Identify Email Provider and Collect Credentials

步骤2:识别邮件服务商并收集凭证

Based on the sender's email address domain, identify the email provider and request the appropriate credentials.
根据发件人邮箱的域名识别邮件服务商,并请求相应的凭证。

Email Provider Detection

邮件服务商检测

@gmail.com, @googlemail.com   → Gmail
@outlook.com, @hotmail.com, @live.com, @office365.com → Outlook/Office 365
@qq.com, @vip.qq.com          → QQ Mail
@163.com, @126.com            → NetEase Mail
@aliyun.com, @aliyun-inc.com  → Aliyun Mail
@sendgrid.net, @*.sendgrid.net → SendGrid
@*.mailgun.org                → Mailgun
Other domains                  → Custom SMTP (ask for server, port, username, password)
@gmail.com, @googlemail.com   → Gmail
@outlook.com, @hotmail.com, @live.com, @office365.com → Outlook/Office 365
@qq.com, @vip.qq.com          → QQ邮箱
@163.com, @126.com            → 网易邮箱
@aliyun.com, @aliyun-inc.com  → 阿里云邮箱
@sendgrid.net, @*.sendgrid.net → SendGrid
@*.mailgun.org                → Mailgun
其他域名                  → 自定义SMTP(需提供服务器、端口、用户名、密码)

Provider-Specific Credential Requirements

各服务商的凭证要求

Gmail (@gmail.com, @googlemail.com)
  • Password Type: App Password (NOT account password)
  • Prerequisite: Two-factor authentication (2FA) must be enabled
  • How to get App Password:
    1. Go to https://myaccount.google.com/apppasswords
    2. Sign in to your Google Account
    3. Select "Mail" and "Other (Custom name)" → Enter a name like "SMTP Script"
    4. Click "Generate" → Copy the 16-character password
  • SMTP Server:
    smtp.gmail.com
  • Port:
    587
    (TLS) or
    465
    (SSL)
  • Username: Your full Gmail address
Outlook / Office 365 (@outlook.com, @hotmail.com, @live.com, @office365.com)
  • Password Type: Account password (same as web login)
  • SMTP Server:
    smtp.office365.com
  • Port:
    587
    (TLS)
  • Username: Your full Outlook/Office 365 email address
QQ Mail (@qq.com, @vip.qq.com)
  • Password Type: SMTP Authorization Code (NOT account password)
  • How to get Authorization Code:
    1. Login to QQ Mail at https://mail.qq.com
    2. Click "Settings" (设置) → "Account" (账户)
    3. Find "POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV Service"
    4. Open "POP3/SMTP Service" or "IMAP/SMTP Service"
    5. Click "Generate Authorization Code" (生成授权码)
    6. Verify identity via SMS → Copy the generated code
  • SMTP Server:
    smtp.qq.com
  • Port:
    587
    (TLS) or
    465
    (SSL)
  • Username: Your full QQ email address
NetEase 163 Mail (@163.com)
  • Password Type: SMTP Authorization Code (NOT account password)
  • How to get Authorization Code:
    1. Login to 163 Mail at https://mail.163.com
    2. Click "Settings" (设置) → "POP3/SMTP/IMAP"
    3. Click "Open" next to "IMAP/SMTP Service"
    4. Verify identity → Click "Get Authorization Code" (获取授权码)
    5. Copy the 16-character authorization code
  • SMTP Server:
    smtp.163.com
  • Port:
    465
    (SSL) or
    994
    (IMAP)
  • Username: Your full 163 email address
NetEase 126 Mail (@126.com)
  • Password Type: SMTP Authorization Code (NOT account password)
  • How to get Authorization Code:
    1. Login to 126 Mail at https://mail.126.com
    2. Click "Settings" (设置) → "POP3/SMTP/IMAP"
    3. Enable "IMAP/SMTP Service"
    4. Copy the authorization password displayed
  • SMTP Server:
    smtp.126.com
  • Port:
    465
    (SSL) or
    25
    (SSL)
  • Username: Your full 126 email address
SendGrid
  • Password Type: API Key (as password)
  • How to get API Key:
    1. Login to SendGrid at https://app.sendgrid.com
    2. Go to Settings → API Keys
    3. Click "Create API Key"
    4. Set permissions → Click "Create & View"
    5. Copy the API key (only shown once)
  • SMTP Server:
    smtp.sendgrid.net
  • Port:
    587
    (TLS) or
    465
    (SSL)
  • Username:
    apikey
    (literally this string)
Mailgun
  • Password Type: SMTP credentials from dashboard
  • How to get Credentials:
    1. Login to Mailgun at https://app.mailgun.com
    2. Go to Sending → Domains
    3. Select your domain
    4. Copy SMTP username and password from the page
  • SMTP Server:
    smtp.mailgun.org
  • Port:
    587
    (TLS)
  • Username: From Mailgun dashboard
Custom SMTP (Other domains) Ask the user to provide:
  • SMTP Server Address
  • SMTP Port
  • Username
  • Password
Gmail (@gmail.com, @googlemail.com)
  • 密码类型:应用专用密码(非账户密码)
  • 前提条件:必须启用双因素认证(2FA)
  • 如何获取应用专用密码
    1. 访问 https://myaccount.google.com/apppasswords
    2. 登录你的Google账户
    3. 选择“邮件”和“其他(自定义名称)” → 输入名称如“SMTP脚本”
    4. 点击“生成” → 复制16位密码
  • SMTP服务器
    smtp.gmail.com
  • 端口
    587
    (TLS)或
    465
    (SSL)
  • 用户名:你的完整Gmail邮箱地址
Outlook / Office 365 (@outlook.com, @hotmail.com, @live.com, @office365.com)
  • 密码类型:账户密码(与网页登录密码相同)
  • SMTP服务器
    smtp.office365.com
  • 端口
    587
    (TLS)
  • 用户名:你的完整Outlook/Office 365邮箱地址
QQ邮箱 (@qq.com, @vip.qq.com)
  • 密码类型:SMTP授权码(非账户密码)
  • 如何获取授权码
    1. 登录QQ邮箱 https://mail.qq.com
    2. 点击“设置” → “账户”
    3. 找到“POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务”
    4. 开启“POP3/SMTP服务”或“IMAP/SMTP服务”
    5. 点击“生成授权码”
    6. 通过短信验证身份 → 复制生成的授权码
  • SMTP服务器
    smtp.qq.com
  • 端口
    587
    (TLS)或
    465
    (SSL)
  • 用户名:你的完整QQ邮箱地址
网易163邮箱 (@163.com)
  • 密码类型:SMTP授权码(非账户密码)
  • 如何获取授权码
    1. 登录163邮箱 https://mail.163.com
    2. 点击“设置” → “POP3/SMTP/IMAP”
    3. 点击“IMAP/SMTP服务”旁的“开启”
    4. 验证身份 → 点击“获取授权码”
    5. 复制16位授权码
  • SMTP服务器
    smtp.163.com
  • 端口
    465
    (SSL)或
    994
    (IMAP)
  • 用户名:你的完整163邮箱地址
网易126邮箱 (@126.com)
  • 密码类型:SMTP授权码(非账户密码)
  • 如何获取授权码
    1. 登录126邮箱 https://mail.126.com
    2. 点击“设置” → “POP3/SMTP/IMAP”
    3. 启用“IMAP/SMTP服务”
    4. 复制显示的授权密码
  • SMTP服务器
    smtp.126.com
  • 端口
    465
    (SSL)或
    25
    (SSL)
  • 用户名:你的完整126邮箱地址
SendGrid
  • 密码类型:API密钥(作为密码使用)
  • 如何获取API密钥
    1. 登录SendGrid https://app.sendgrid.com
    2. 进入“设置” → “API密钥”
    3. 点击“创建API密钥”
    4. 设置权限 → 点击“创建并查看”
    5. 复制API密钥(仅显示一次)
  • SMTP服务器
    smtp.sendgrid.net
  • 端口
    587
    (TLS)或
    465
    (SSL)
  • 用户名
    apikey
    (固定字符串)
Mailgun
  • 密码类型:控制台中的SMTP凭证
  • 如何获取凭证
    1. 登录Mailgun https://app.mailgun.com
    2. 进入“发送” → “域名”
    3. 选择你的域名
    4. 复制页面中的SMTP用户名和密码
  • SMTP服务器
    smtp.mailgun.org
  • 端口
    587
    (TLS)
  • 用户名:来自Mailgun控制台
自定义SMTP(其他域名) 向用户询问以下信息:
  • SMTP服务器地址
  • SMTP端口
  • 用户名
  • 密码

Step 3: Auto-detect and Handle Markdown Content

步骤3:自动检测并处理Markdown内容

The script automatically detects if the email content is in Markdown format by looking for common patterns:
  • Headers (
    #
    ,
    ##
    ,
    ###
    )
  • Bold/italic text (
    **bold**
    ,
    *italic*
    )
  • Lists (
    - item
    or
    1. item
    )
  • Code blocks (```)
  • Links (
    [text](url)
    )
If Markdown is detected, the content is automatically converted to beautifully styled HTML with:
  • Professional typography and spacing
  • Color-coded headers
  • Styled tables and code blocks
  • Responsive design for email clients
You don't need to manually specify
--content-type html
for Markdown content
- it's handled automatically!
脚本会通过查找常见格式自动检测邮件内容是否为Markdown格式:
  • 标题(
    #
    ##
    ###
  • 粗体/斜体文本(
    **粗体**
    *斜体*
  • 列表(
    - 项目
    1. 项目
  • 代码块(```)
  • 链接(
    [文本](网址)
如果检测到Markdown格式,内容会自动转换为样式美观的HTML,包含:
  • 专业的排版和间距
  • 颜色区分的标题
  • 样式化的表格和代码块
  • 适配邮件客户端的响应式设计
无需手动指定
--content-type html
来处理Markdown内容
——会自动处理!

Step 4: Collect Optional Information (if needed)

步骤4:收集可选信息(如需)

  • --from-name
    : Display name for sender (e.g., "John Doe")
  • --content-type html
    : For HTML formatted emails (defaults to plain text, but auto-converts Markdown)
  • --attach
    : File path(s) to attach (can specify multiple)
  • --template
    : Use template file instead of content
  • --template-vars
    : JSON string of template variables
  • --from-name
    :发件人显示名称(例如:“张三”)
  • --content-type html
    :用于HTML格式邮件(默认是纯文本,但会自动转换Markdown)
  • --attach
    :要附加的文件路径(可指定多个)
  • --template
    :使用模板文件替代直接输入内容
  • --template-vars
    :模板变量的JSON字符串

Step 5: Confirm and Send

步骤5:确认并发送

Before sending, confirm with the user:
Ready to send:
From: [Sender Email]
To: [Recipient Email]
Subject: [Subject]
Content Type: [Plain/HTML]
Attachments: [List of attachments or None]

Proceed to send? (y/n)
If confirmed, execute the send_email.py script with all collected parameters.
发送前,与用户确认:
准备发送:
发件人:[发件人邮箱]
收件人:[收件人邮箱]
主题:[主题]
内容类型:[纯文本/HTML]
附件:[附件列表或无]

是否继续发送?(y/n)
若用户确认,使用收集到的所有参数执行send_email.py脚本。

Example Conversations

示例对话

Example 1: Basic Gmail Email

示例1:基础Gmail邮件

User: Send an email to john@example.com with subject "Hello"
Skill: I can help you send that email. I need a few more details:
  1. Content: What should the email body contain?
  2. Sender Email: What email address should I send from?
User: The content is "Hi John, just saying hello!" and send from myemail@gmail.com
Skill: I detected you're using Gmail. For Gmail, you need an App Password (not your regular password).
To get your App Password:
  1. Go to https://myaccount.google.com/apppasswords
  2. Sign in and create an App Password for "Mail"
  3. Copy the 16-character password
Please provide your Gmail App Password:
User: abcd efgh ijkl mnop
Skill: Ready to send:
  • From: myemail@gmail.com
  • To: john@example.com
  • Subject: Hello
  • Content: Hi John, just saying hello!
Proceed to send? (y/n)

用户:给john@example.com发送主题为“Hello”的邮件
工具:我可以帮您发送这封邮件,还需要一些信息:
  1. 内容:邮件正文应该包含什么?
  2. 发件人邮箱:应该从哪个邮箱发送?
用户:内容是“Hi John, just saying hello!”,从myemail@gmail.com发送
工具:检测到您使用的是Gmail。Gmail需要应用专用密码(而非常规密码)。
获取应用专用密码的步骤:
  1. 访问 https://myaccount.google.com/apppasswords
  2. 登录账户并为“邮件”创建应用专用密码
  3. 复制16位密码
请提供您的Gmail应用专用密码:
用户:abcd efgh ijkl mnop
工具:准备发送:
  • 发件人:myemail@gmail.com
  • 收件人:john@example.com
  • 主题:Hello
  • 内容:Hi John, just saying hello!
是否继续发送?(y/n)

Example 2: Markdown Content with Default Sender

示例2:含Markdown内容的默认发件人邮件

User: 发一封邮件给 manager@company.com,主题是"AR眼镜行业分析",内容是 [用户提供的 Markdown 报告]
Skill: 我来帮您发送这封邮件。检测到您没有指定发件人邮箱,我将使用默认邮箱
agent_skill_test@126.com
发送。
同时,我发现您的内容是 Markdown 格式,将自动转换为美观的 HTML 格式,让报告更易读。
为了使用 126 邮箱发送,我需要您提供 SMTP 授权码
获取授权码步骤:
  1. 登录 126 邮箱 → 设置 → POP3/SMTP/IMAP
  2. 启用 "IMAP/SMTP 服务"
  3. 复制显示的授权密码
请提供 agent_skill_test@126.com 的授权码:
User: [提供授权码]
Skill: 准备发送邮件:
  • 发件人: agent_skill_test@126.com
  • 收件人: manager@company.com
  • 主题: AR眼镜行业分析
  • 格式: Markdown → HTML (自动转换)
  • 内容预览: 包含标题、列表、表格等格式化内容
确认发送? (y/n)

用户:给manager@company.com发送主题为“AR眼镜行业分析”的邮件,内容是[用户提供的Markdown报告]
工具:我来帮您发送这封邮件。检测到您未指定发件人邮箱,将使用默认邮箱
agent_skill_test@126.com
发送。
同时,我发现您的内容是Markdown格式,会自动转换为美观的HTML格式,让报告更易读。
为使用126邮箱发送,需要您提供SMTP授权码
获取授权码步骤:
  1. 登录126邮箱 → 设置 → POP3/SMTP/IMAP
  2. 启用“IMAP/SMTP服务”
  3. 复制显示的授权密码
请提供agent_skill_test@126.com的授权码:
用户:[提供授权码]
工具:准备发送邮件:
  • 发件人: agent_skill_test@126.com
  • 收件人: manager@company.com
  • 主题: AR眼镜行业分析
  • 格式: Markdown → HTML(自动转换)
  • 内容预览: 包含标题、列表、表格等格式化内容
确认发送?(y/n)

Example 3: Default Sender with Missing Content

示例3:默认发件人且缺失内容的情况

User: 发邮件给 user@company.com,主题是项目报告
Skill: 我需要收集邮件内容:
邮件正文是什么?
User: 项目已完成,所有里程碑都已达成。
Skill: 我将使用默认邮箱
agent_skill_test@126.com
发送。
为了使用 126 邮箱发送,我需要您提供 SMTP 授权码
获取授权码步骤:
  1. 登录 126 邮箱 → 设置 → POP3/SMTP/IMAP
  2. 启用 "IMAP/SMTP 服务"
  3. 复制显示的授权密码
请提供 agent_skill_test@126.com 的授权码:
User: [提供授权码]
Skill: 准备发送邮件:
  • 发件人: agent_skill_test@126.com
  • 收件人: user@company.com
  • 主题: 项目报告
  • 内容: 项目已完成,所有里程碑都已达成。
确认发送?(y/n)

用户:给user@company.com发送主题为“项目报告”的邮件
工具:我需要收集邮件内容:
邮件正文是什么?
用户:项目已完成,所有里程碑都已达成。
工具:将使用默认邮箱
agent_skill_test@126.com
发送。
为使用126邮箱发送,需要您提供SMTP授权码
获取授权码步骤:
  1. 登录126邮箱 → 设置 → POP3/SMTP/IMAP
  2. 启用“IMAP/SMTP服务”
  3. 复制显示的授权密码
请提供agent_skill_test@126.com的授权码:
用户:[提供授权码]
工具:准备发送邮件:
  • 发件人: agent_skill_test@126.com
  • 收件人: user@company.com
  • 主题: 项目报告
  • 内容: 项目已完成,所有里程碑都已达成。
确认发送?(y/n)

Example 4: User Specifies Custom Sender Email

示例4:用户指定自定义发件人邮箱

User: Send a report to boss@company.com from myname@outlook.com about Q4 results, with attachment /home/user/q4_report.pdf
Skill: I'll help you send that email. Please provide the email content:
What should the email say about the Q4 results?
User: Please find attached the Q4 financial report. Let me know if you have any questions.
Skill: I see you're using Outlook. You'll need your Outlook account password (same as web login).
Please provide your Outlook password:
User: mypassword123
Skill: Ready to send:
  • From: myname@outlook.com
  • To: boss@company.com
  • Subject: Q4 results
  • Content: Please find attached the Q4 financial report. Let me know if you have any questions.
  • Attachment: /home/user/q4_report.pdf
Proceed to send? (y/n)

用户:从myname@outlook.comboss@company.com发送关于Q4业绩的报告,附件是/home/user/q4_report.pdf
工具:我会帮您发送这封邮件,请提供邮件内容:
关于Q4业绩的邮件内容应该怎么写?
用户:请查收附件中的Q4财务报告,如有疑问请随时告知。
工具:我看到您使用的是Outlook,需要您的Outlook账户密码(与网页登录密码相同)。
请提供您的Outlook密码:
用户:mypassword123
工具:准备发送:
  • 发件人: myname@outlook.com
  • 收件人: boss@company.com
  • 主题: Q4 results
  • 内容: Please find attached the Q4 financial report. Let me know if you have any questions.
  • 附件: /home/user/q4_report.pdf
是否继续发送?(y/n)

Example 5: Custom SMTP

示例5:自定义SMTP

User: Send email to test@domain.com from my@domain.com
Skill: I need to gather some information:
  1. Subject: What is the email subject?
  2. Content: What is the email body?
User: Subject is Test Email, content is Hello World
Skill: Since you're using a custom domain (my@domain.com), I'll need your SMTP configuration:
  1. SMTP Server: What is your SMTP server address?
  2. SMTP Port: What port should I use?
  3. Username: What is your SMTP username?
  4. Password: What is your SMTP password?
User: Server is smtp.mydomain.com, port 587, username is my@domain.com, password is secret
Skill: Ready to send:
  • From: my@domain.com
  • To: test@domain.com
  • Subject: Test Email
  • Content: Hello World
  • SMTP Server: smtp.mydomain.com:587
Proceed to send? (y/n)
用户:从my@domain.comtest@domain.com发送邮件
工具:我需要收集一些信息:
  1. 主题:邮件主题是什么?
  2. 内容:邮件正文是什么?
用户:主题是Test Email,内容是Hello World
工具:由于您使用的是自定义域名(my@domain.com),需要您提供SMTP配置信息:
  1. SMTP服务器:您的SMTP服务器地址是什么?
  2. SMTP端口:应该使用哪个端口?
  3. 用户名:您的SMTP用户名是什么?
  4. 密码:您的SMTP密码是什么?
用户:服务器是smtp.mydomain.com,端口587,用户名是my@domain.com,密码是secret
工具:准备发送:
  • 发件人: my@domain.com
  • 收件人: test@domain.com
  • 主题: Test Email
  • 内容: Hello World
  • SMTP服务器: smtp.mydomain.com:587
是否继续发送?(y/n)

Script Command Reference

脚本命令参考

Once all information is collected, execute the script with appropriate parameters:
收集完所有信息后,使用相应参数执行脚本:

Basic Command

基础命令

bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "Email body content" \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password-or-app-password
bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "Email body content" \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password-or-app-password

HTML Email

HTML格式邮件

bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "<h1>Hello</h1><p>HTML content</p>" \
  --content-type html \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password
bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "<h1>Hello</h1><p>HTML content</p>" \
  --content-type html \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password

Email with Attachments

带附件的邮件

bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "Email body" \
  --attach /path/to/file1.pdf \
  --attach /path/to/file2.csv \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password
bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "Email body" \
  --attach /path/to/file1.pdf \
  --attach /path/to/file2.csv \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password

Email with Template

使用模板的邮件

bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --template assets/simple-notification.html \
  --template-vars '{"title":"Notification","message":"Your report is ready!"}' \
  --content-type html \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password
bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --template assets/simple-notification.html \
  --template-vars '{"title":"Notification","message":"Your report is ready!"}' \
  --content-type html \
  --smtp-server smtp.gmail.com \
  --smtp-port 587 \
  --username your@email.com \
  --password your-password

SSL Connection (instead of TLS)

SSL连接(替代TLS)

bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "Email body" \
  --smtp-server smtp.gmail.com \
  --smtp-port 465 \
  --use-ssl \
  --username your@email.com \
  --password your-password
bash
python3 scripts/send_email.py \
  --to recipient@example.com \
  --subject "Email Subject" \
  --content "Email body" \
  --smtp-server smtp.gmail.com \
  --smtp-port 465 \
  --use-ssl \
  --username your@email.com \
  --password your-password

SMTP Server Configuration Reference

SMTP服务器配置参考

ProviderSMTP ServerPortEncryptionPassword TypeUsername
Gmailsmtp.gmail.com587TLSApp PasswordFull email
Gmailsmtp.gmail.com465SSLApp PasswordFull email
Outlooksmtp.office365.com587TLSAccount PasswordFull email
QQ Mailsmtp.qq.com587TLSAuthorization CodeFull email
QQ Mailsmtp.qq.com465SSLAuthorization CodeFull email
163 Mailsmtp.163.com465SSLAuthorization CodeFull email
163 Mailsmtp.163.com994SSLAuthorization CodeFull email
126 Mailsmtp.126.com465SSLAuthorization CodeFull email
126 Mailsmtp.126.com25SSLAuthorization CodeFull email
SendGridsmtp.sendgrid.net587TLSAPI Key
apikey
SendGridsmtp.sendgrid.net465SSLAPI Key
apikey
Mailgunsmtp.mailgun.org587TLSSMTP PasswordFrom dashboard
服务商SMTP服务器端口加密方式密码类型用户名
Gmailsmtp.gmail.com587TLS应用专用密码完整邮箱
Gmailsmtp.gmail.com465SSL应用专用密码完整邮箱
Outlooksmtp.office365.com587TLS账户密码完整邮箱
QQ邮箱smtp.qq.com587TLS授权码完整邮箱
QQ邮箱smtp.qq.com465SSL授权码完整邮箱
163邮箱smtp.163.com465SSL授权码完整邮箱
163邮箱smtp.163.com994SSL授权码完整邮箱
126邮箱smtp.126.com465SSL授权码完整邮箱
126邮箱smtp.126.com25SSL授权码完整邮箱
SendGridsmtp.sendgrid.net587TLSAPI密钥
apikey
SendGridsmtp.sendgrid.net465SSLAPI密钥
apikey
Mailgunsmtp.mailgun.org587TLSSMTP密码来自控制台

Installation

安装

Before using this skill, install the required Python dependencies:
bash
pip install -r requirements.txt
This installs the
markdown
library (version ≥3.4.0) which is required for automatic Markdown to HTML conversion.
使用该工具前,安装所需的Python依赖:
bash
pip install -r requirements.txt
这会安装
markdown
库(版本≥3.4.0),用于自动将Markdown转换为HTML。

Resources

资源说明

scripts/send_email.py

scripts/send_email.py

Main Python script for sending emails. Supports:
  • Plain text and HTML content
  • Multiple file attachments
  • Email templates with variable substitution
  • TLS and SSL encryption
  • Custom sender names
用于发送邮件的主Python脚本,支持:
  • 纯文本和HTML内容
  • 多个文件附件
  • 带变量替换的邮件模板
  • TLS和SSL加密
  • 自定义发件人名称

references/smtp-servers.md

references/smtp-servers.md

Common SMTP server configurations including Gmail, Outlook, 126, QQ, 163, SendGrid, Mailgun, and Aliyun.
常见SMTP服务器配置,包括Gmail、Outlook、126、QQ、163、SendGrid、Mailgun和阿里云邮箱。

assets/

assets/

Email templates:
  • simple-notification.html
    - Basic notification template
  • report-summary.html
    - Professional report template with metrics grid
邮件模板:
  • simple-notification.html
    - 基础通知模板
  • report-summary.html
    - 带指标网格的专业报告模板