chore(workspace-resume): 配置清理与维护同步(2026-07-31)
- 精简 AGENTS.md 为中文版,新增核心职责声明 - MEMORY.md 补安全红线中文存档、抄送去除 wurd - TOOLS.md 中文化,记录 IMAP 邮箱配置 - USER.md 团队同事去除 wurd - send_weekly_report.py 硬编码密码迁移 .env、抄送去除吴睿东 - weekly-report-g5 SKILL.md 抄送去除 wurd - 旧散装周报移入 .trash 回收站(可恢复) - 新增 .trash 目录、memory/2026-07-31.md、2026-W31 周报 注:.env 已被 .gitignore 忽略,不包含密码
This commit is contained in:
@@ -8,17 +8,41 @@ from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.header import Header
|
||||
import imaplib
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
def load_env(path):
|
||||
"""读取 .env 文件,返回键值字典(标准库实现,无额外依赖)。"""
|
||||
env = {}
|
||||
try:
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#') or '=' not in line:
|
||||
continue
|
||||
key, _, value = line.partition('=')
|
||||
env[key.strip()] = value.strip().strip('"').strip("'")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return env
|
||||
|
||||
|
||||
_ENV = load_env(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '.env'))
|
||||
|
||||
IMAP_HOST = 'imap.mxhichina.com'
|
||||
IMAP_PORT = 993
|
||||
IMAP_USER = _ENV.get('WITSOFT_IMAP_USER', 'yangxuan@witsoft.cn')
|
||||
IMAP_PASSWORD = _ENV.get('WITSOFT_IMAP_PASSWORD', '')
|
||||
|
||||
def send_to_drafts(plain_body: str, html_body: str, date_range: str):
|
||||
"""构造多段邮件并存入钉邮草稿箱"""
|
||||
msg = MIMEMultipart('related')
|
||||
msg['From'] = Header('杨轩', 'utf-8').encode() + ' <yangxuan@witsoft.cn>'
|
||||
msg['To'] = Header('刘强', 'utf-8').encode() + ' <liuqiang@witsoft.cn>'
|
||||
msg['Cc'] = (
|
||||
Header('吴睿东', 'utf-8').encode() + ' <wurd@witsoft.cn>, '
|
||||
+ Header('陈明', 'utf-8').encode() + ' <chenm@witsoft.cn>, '
|
||||
Header('陈明', 'utf-8').encode() + ' <chenm@witsoft.cn>, '
|
||||
+ Header('曾莉', 'utf-8').encode() + ' <zengli@witsoft.cn>'
|
||||
)
|
||||
msg['Subject'] = Header(f'G5开发周报 ({date_range})', 'utf-8').encode()
|
||||
@@ -30,8 +54,8 @@ def send_to_drafts(plain_body: str, html_body: str, date_range: str):
|
||||
|
||||
raw_bytes = msg.as_bytes()
|
||||
|
||||
conn = imaplib.IMAP4_SSL('imap.mxhichina.com', 993)
|
||||
conn.login('yangxuan@witsoft.cn', '5gynj20J')
|
||||
conn = imaplib.IMAP4_SSL(IMAP_HOST, IMAP_PORT)
|
||||
conn.login(IMAP_USER, IMAP_PASSWORD)
|
||||
|
||||
drafts = '"&g0l6Pw-"'
|
||||
result = conn.append(drafts, None, imaplib.Time2Internaldate(time.time()), raw_bytes)
|
||||
|
||||
Reference in New Issue
Block a user