← 返回
未分类 Key

阿里云企业邮箱skill

This skill should be used whenever the task involves sending, reading, or managing emails via Aliyun Enterprise Email (阿里企业邮箱). It covers SMTP email sending, IMAP email reading, bounce (退信) detection and reporting, invoice attachment validation, and automation scheduling. Trigger when the user mentions 阿里企业邮箱, SMTP, IMAP, 退信检查, 发票邮件, or email automation tasks.
This skill should be used whenever the task involves sending, reading, or managing emails via Aliyun Enterprise Email (阿里企业邮箱). It covers SMTP email sending, IMAP email reading, bounce (退信) detection and reporting, invoice attachment validation, and automation scheduling. Trigger when the user mentions 阿里企业邮箱, SMTP, IMAP, 退信检查, 发票邮件, or email automation tasks.
user_511a8129
未分类 community v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 70
下载
💾 0
安装
1
版本
#latest

概述

Aliyun Email (阿里企业邮箱对接)

Overview

This skill provides everything needed to integrate with Aliyun Enterprise Email (阿里企业邮箱) using Python's standard smtplib and imaplib — no third-party libraries required. It covers sending, reading, bounce detection, and invoice attachment validation.

Connection Parameters:

  • SMTP: smtp.qiye.aliyun.com port 465 (SSL) or 25 (plain)
  • IMAP: imap.qiye.aliyun.com port 993 (SSL)
  • 已发送文件夹 (Sent): IMAP name = &XfJT0ZAB- (UTF-7 encoded)

See references/aliyun_email_config.md for full config reference including folder names, SSL troubleshooting, SMTP error codes, and IMAP search syntax.


Core Tasks

1. Send Email (SMTP)

Use scripts/email_client.pyAliyunEmailClient.send_email():

from scripts.email_client import AliyunEmailClient

client = AliyunEmailClient(
    username='your@example.com',
    password='your_auth_code',
    display_name='财务部'
)

# HTML email with attachment
result = client.send_email(
    subject='月度报表',
    to=['manager@example.com', 'boss@example.com'],
    cc=['assistant@example.com'],
    html_content='<h1>月度财务报表</h1><p>请查收附件</p>',
    text_content='月度财务报表,请查收附件',
    attachments=['/path/to/report.xlsx']
)
print(result)  # {'success': True, 'message': '邮件发送成功', 'recipients': [...]}

Parameters:

  • to / cc / bcc: str or list of str
  • html_content / text_content: body (use at least one)
  • attachments: list of local file paths
  • url_attachments: list of URLs to download and attach
  • use_ssl=True for port 465; use_ssl=False for port 25

2. Read Emails (IMAP)

client = AliyunEmailClient(username='...', password='...')
try:
    # List inbox emails
    emails = client.list_emails(folder='INBOX', limit=20)
    for m in emails:
        print(f"[{m['uid']}] {m['date']} | {m['subject']}")

    # Read sent folder
    sent = client.list_emails(folder='&XfJT0ZAB-', since_days=1)

    # Get full content
    content = client.get_email_content(uid='123', folder='INBOX')
    print(content['body_text'])
    for att in content['attachments']:
        print(att['filename'], att['size'])

    # Download attachment
    client.download_attachment(uid='123', filename='report.pdf', save_path='/tmp/report.pdf')
finally:
    client.close()

list_emails() filter options:

  • unseen_only=True — unread only
  • since_days=N — last N days
  • since_date='25-Mar-2026' / before_date='26-Mar-2026' — date range (DD-Mon-YYYY)
  • subject_keyword='发票' — filter by subject

3. Check Bounce Emails (退信检查)

Run scripts/check_bounced.py or import as a module:

from scripts.check_bounced import check_bounced_emails
from datetime import date

bounces = check_bounced_emails(
    username='your@example.com',
    password='auth_code',
    check_date=date(2026, 3, 25),      # defaults to yesterday if omitted
    output_dir='./check_result',        # CSV saved here
    own_domain='yourdomain.com'         # exclude own addresses from recipient extraction
)
# Returns list of bounce dicts, also saves bounce_report_YYYYMMDD.csv

Command line:

python scripts/check_bounced.py your@example.com auth_code 2026-03-25 ./check_result yourdomain.com

CSV output fields: 邮件主题, 发送时间, 收信地址, 退信原因, 解决方案, 退信正文预览

Bounce detection: The script identifies bounces by checking From field (mailer-daemon, postmaster) and Subject keywords (undeliverable, delivery failed, 退信, etc.). It then extracts the original recipient from the body — prioritizing the Aliyun-specific pattern 无法发送到 xxx@xxx.com.

4. Check Invoice Attachment Count (发票邮件检查)

Run scripts/check_invoices.py or import as a module:

from scripts.check_invoices import check_invoice_emails

result = check_invoice_emails(
    username='your@example.com',
    password='auth_code',
    date_str='2026-03-25',
    output_dir='./check_result',
    alert_recipients=['admin@example.com'],   # notify on mismatch
    sent_folder='&XfJT0ZAB-'                  # Aliyun sent folder
)
# Returns {'success': True, 'total_emails': N, 'checked_emails': N,
#          'matched': N, 'mismatched': N, 'report_file': '...'}

Rules:

  • Only processes emails where subject contains X张 (e.g., "发票3张")
  • 1-invoice emails: checks for PDF attachment presence
  • Multi-invoice emails: unzips ZIP attachment, counts files ÷ 3 (each invoice = PDF + OFD + XML)
  • On mismatch: sends HTML alert email with details and attached CSV report

Command line:

python scripts/check_invoices.py your@example.com auth_code 2026-03-25 ./result admin@example.com

Common Patterns

List available folders (to find sent folder name)

client = AliyunEmailClient(username='...', password='...')
for f in client.list_folders():
    print(f['name'])
client.close()

Create and run an automated daily check

When the user wants a recurring automation (e.g., "每天检查退信"), use WorkBuddy's automation feature to schedule check_bounced.py or check_invoices.py to run daily.


Resources

  • scripts/email_client.py — Full SMTP + IMAP client (AliyunEmailClient class)
  • scripts/check_bounced.py — Bounce email detection and CSV report
  • scripts/check_invoices.py — Invoice attachment count validation
  • references/aliyun_email_config.md — Server config, folder names, SSL notes, SMTP error codes

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-05-13 10:58 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,055 📥 795,847
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,210 📥 266,145
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 666 📥 323,786