simtoolsz 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
simtoolsz/__init__.py ADDED
@@ -0,0 +1,12 @@
1
+ import importlib.metadata
2
+
3
+ import mail
4
+
5
+ try:
6
+ __version__ = importlib.metadata.version("simtoolsz")
7
+ except importlib.metadata.PackageNotFoundError:
8
+ __version__ = "0.1.0"
9
+
10
+ __all__ = [
11
+ '__version__', 'mail'
12
+ ]
simtoolsz/mail.py ADDED
@@ -0,0 +1,617 @@
1
+ import imaplib
2
+ import email
3
+ import os
4
+ import smtplib
5
+ import mimetypes
6
+ from pathlib import Path
7
+ from typing import List, Dict, Union, Optional, Tuple, Any
8
+ from email.mime.multipart import MIMEMultipart
9
+ from email.mime.text import MIMEText
10
+ from email.mime.application import MIMEApplication
11
+ from email.mime.image import MIMEImage
12
+ from email.utils import formataddr
13
+ from email.header import Header
14
+ from email.header import decode_header
15
+ from datetime import datetime, timedelta
16
+
17
+
18
+
19
+ def send_email(
20
+ email_account: str,
21
+ password: str,
22
+ subject: str,
23
+ content: str,
24
+ recipients: Union[str, List[str], List[Tuple[str, str]]],
25
+ attachments: Optional[List[Union[Path, str]]] = None,
26
+ cc_recipients: Optional[Union[str, List[str], List[Tuple[str, str]]]] = None,
27
+ bcc_recipients: Optional[Union[str, List[str], List[Tuple[str, str]]]] = None,
28
+ html_mode: bool = False,
29
+ sender_name: Optional[str] = None,
30
+ signature: Optional[str] = None,
31
+ inline_images: Optional[Dict[str, Union[Path, str]]] = None,
32
+ smtp_config: Optional[Dict[str, Any]] = None,
33
+ timeout: int = 30
34
+ ) -> Dict[str, Any]:
35
+ """
36
+ 简单易用的邮件发送函数(支持附件、HTML、内嵌图片等高级功能)
37
+
38
+ 使用示例:
39
+ # 基础用法 - 发送纯文本邮件
40
+ result = send_email(
41
+ email_account="your@qq.com",
42
+ password="your_password",
43
+ subject="测试邮件",
44
+ content="这是一封测试邮件",
45
+ recipients="friend@example.com"
46
+ )
47
+
48
+ # 高级用法 - 发送HTML邮件带附件
49
+ result = send_email(
50
+ email_account="your@gmail.com",
51
+ password="app_password",
52
+ subject="项目报告",
53
+ content="<h1>本月工作报告</h1><p>详见附件</p>",
54
+ recipients=["boss@company.com", "同事<colleague@company.com>"],
55
+ cc_recipients=["assistant@company.com"],
56
+ attachments=["report.pdf", "data.xlsx"],
57
+ html_mode=True,
58
+ sender_name="张三",
59
+ signature="<br><em>此致<br>张三</em>"
60
+ )
61
+
62
+ # 使用内嵌图片
63
+ result = send_email(
64
+ email_account="your@163.com",
65
+ password="auth_code",
66
+ subject="产品展示",
67
+ content='<img src="cid:product1"><p>最新产品图片</p>',
68
+ recipients="client@example.com",
69
+ inline_images={"product1": "product.jpg"},
70
+ html_mode=True
71
+ )
72
+
73
+ Args:
74
+ email_account: 发件人邮箱地址
75
+ password: 邮箱密码或授权码(QQ/163等需要授权码)
76
+ subject: 邮件主题
77
+ content: 邮件正文内容(支持HTML或纯文本)
78
+ recipients: 收件人,可以是:
79
+ - 单个邮箱字符串: "user@example.com"
80
+ - 邮箱列表: ["user1@example.com", "user2@example.com"]
81
+ - 带名称的格式: ["张三<user@example.com>"] 或 [("张三", "user@example.com")]
82
+ attachments: 附件文件路径列表,支持Path对象或字符串
83
+ cc_recipients: 抄送人,格式同recipients
84
+ bcc_recipients: 密送人,格式同recipients
85
+ html_mode: 是否使用HTML格式发送
86
+ sender_name: 发件人显示名称
87
+ signature: 邮件签名内容(自动添加在正文后)
88
+ inline_images: 内嵌图片字典,格式: {"cid名称": "图片路径"}
89
+ smtp_config: 自定义SMTP配置,格式: {"smtp_server": "smtp.xxx.com", "port": 587, "use_ssl": True}
90
+ timeout: 连接超时时间(秒)
91
+
92
+ Returns:
93
+ Dict[str, Any]: 发送结果信息
94
+ {
95
+ "success": bool, # 是否成功
96
+ "message": str, # 结果消息
97
+ "recipient_count": int, # 成功发送的收件人数量
98
+ "smtp_server": str # 使用的SMTP服务器
99
+ }
100
+
101
+ Raises:
102
+ ValueError: 参数验证失败
103
+ RuntimeError: 邮件发送失败
104
+ """
105
+ # 参数验证和预处理
106
+ if not recipients:
107
+ raise ValueError("必须指定至少一个收件人")
108
+
109
+ # 标准化参数格式
110
+ attachments = attachments or []
111
+ cc_recipients = cc_recipients or []
112
+ bcc_recipients = bcc_recipients or []
113
+
114
+ def parse_recipients(recipients):
115
+ """解析收件人参数为标准化格式"""
116
+ if isinstance(recipients, str):
117
+ return [recipients]
118
+ elif isinstance(recipients, (list, tuple)):
119
+ return list(recipients)
120
+ return []
121
+
122
+ all_recipients = parse_recipients(recipients)
123
+ all_cc = parse_recipients(cc_recipients)
124
+ all_bcc = parse_recipients(bcc_recipients)
125
+
126
+ # 创建邮件对象
127
+ msg = MIMEMultipart()
128
+ msg.set_charset("utf-8")
129
+
130
+ # 设置发件人
131
+ if sender_name:
132
+ sender_name = Header(sender_name, "utf-8").encode()
133
+ msg["From"] = formataddr((sender_name, email_account)) if sender_name else email_account
134
+
135
+ def format_recipient_list(recipient_list):
136
+ """格式化收件人列表"""
137
+ formatted = []
138
+ for recipient in recipient_list:
139
+ if isinstance(recipient, tuple) and len(recipient) == 2:
140
+ name, addr = recipient
141
+ name = Header(name, "utf-8").encode()
142
+ formatted.append(formataddr((name, addr)))
143
+ else:
144
+ # 处理字符串格式如 "张三<user@example.com>"
145
+ recipient_str = str(recipient)
146
+ if "<" in recipient_str and ">" in recipient_str:
147
+ name_part = recipient_str.split("<")[0].strip()
148
+ addr_part = recipient_str.split("<")[1].split(">")[0].strip()
149
+ if name_part:
150
+ name_part = Header(name_part, "utf-8").encode()
151
+ formatted.append(formataddr((name_part, addr_part)))
152
+ else:
153
+ formatted.append(addr_part)
154
+ else:
155
+ formatted.append(recipient_str)
156
+ return formatted
157
+
158
+ # 设置收件人
159
+ msg["Subject"] = Header(subject, "utf-8")
160
+ msg["To"] = ", ".join(format_recipient_list(all_recipients))
161
+ if all_cc:
162
+ msg["Cc"] = ", ".join(format_recipient_list(all_cc))
163
+
164
+ # 处理邮件正文和签名
165
+ full_content = content
166
+ if signature:
167
+ if html_mode:
168
+ full_content += f"<br><br>{signature}"
169
+ else:
170
+ full_content += f"\n\n{signature}"
171
+
172
+ # 添加邮件正文
173
+ if html_mode:
174
+ msg.attach(MIMEText(full_content, "html", "utf-8"))
175
+ else:
176
+ msg.attach(MIMEText(full_content, "plain", "utf-8"))
177
+
178
+ # 添加内嵌图片
179
+ if inline_images:
180
+ mimetypes.init()
181
+ for cid, img_path in inline_images.items():
182
+ img_path = Path(img_path)
183
+ if not img_path.exists():
184
+ raise FileNotFoundError(f"内嵌图片文件不存在: {img_path}")
185
+
186
+ mime_type, _ = mimetypes.guess_type(img_path.name)
187
+ if not mime_type or not mime_type.startswith("image/"):
188
+ raise ValueError(f"文件类型不支持或不是图片: {img_path}")
189
+
190
+ try:
191
+ with open(img_path, "rb") as img_file:
192
+ img_data = img_file.read()
193
+
194
+ _, subtype = mime_type.split("/", 1)
195
+ img_part = MIMEImage(img_data, _subtype=subtype)
196
+ img_part.add_header("Content-ID", f"<{cid}>")
197
+ img_part.add_header("Content-Disposition", "inline",
198
+ filename=Header(img_path.name, "utf-8").encode())
199
+ msg.attach(img_part)
200
+ except Exception as e:
201
+ raise RuntimeError(f"处理内嵌图片失败 {img_path}: {e}")
202
+
203
+ # 添加附件
204
+ for attachment in attachments:
205
+ file_path = Path(attachment)
206
+ if not file_path.exists():
207
+ raise FileNotFoundError(f"附件文件不存在: {file_path}")
208
+
209
+ try:
210
+ with open(file_path, "rb") as f:
211
+ file_data = f.read()
212
+
213
+ part = MIMEApplication(file_data, Name=Header(file_path.name, "utf-8").encode())
214
+ part.add_header("Content-Disposition", "attachment",
215
+ filename=Header(file_path.name, "utf-8").encode())
216
+ msg.attach(part)
217
+ except Exception as e:
218
+ raise RuntimeError(f"处理附件失败 {file_path}: {e}")
219
+
220
+ # 自动配置SMTP服务器
221
+ domain = email_account.split("@")[-1].lower()
222
+ default_smtp_config = {
223
+ "gmail.com": {"smtp_server": "smtp.gmail.com", "port": 587, "use_ssl": False},
224
+ "qq.com": {"smtp_server": "smtp.qq.com", "port": 465, "use_ssl": True},
225
+ "163.com": {"smtp_server": "smtp.163.com", "port": 465, "use_ssl": True},
226
+ "126.com": {"smtp_server": "smtp.126.com", "port": 465, "use_ssl": True},
227
+ "outlook.com": {"smtp_server": "smtp-mail.outlook.com", "port": 587, "use_ssl": False},
228
+ "hotmail.com": {"smtp_server": "smtp-mail.outlook.com", "port": 587, "use_ssl": False},
229
+ "chinaott.net": {"smtp_server": "smtp.exmail.qq.com", "port": 465, "use_ssl": True},
230
+ }
231
+
232
+ # 使用自定义配置或自动配置
233
+ if smtp_config:
234
+ smtp_server = smtp_config.get("smtp_server")
235
+ port = smtp_config.get("port", 587)
236
+ use_ssl = smtp_config.get("use_ssl", False)
237
+ else:
238
+ if domain not in default_smtp_config:
239
+ raise ValueError(f"不支持的邮箱服务商: {domain},请提供自定义smtp_config")
240
+ config = default_smtp_config[domain]
241
+ smtp_server = config["smtp_server"]
242
+ port = config["port"]
243
+ use_ssl = config["use_ssl"]
244
+
245
+ # 收集所有收件人
246
+ def extract_emails(recipient_list):
247
+ """提取邮箱地址"""
248
+ emails = []
249
+ for recipient in recipient_list:
250
+ if isinstance(recipient, tuple) and len(recipient) == 2:
251
+ emails.append(recipient[1])
252
+ else:
253
+ recipient_str = str(recipient)
254
+ if "<" in recipient_str and ">" in recipient_str:
255
+ addr = recipient_str.split("<")[1].split(">")[0].strip()
256
+ emails.append(addr)
257
+ else:
258
+ emails.append(recipient_str)
259
+ return emails
260
+
261
+ all_emails = extract_emails(all_recipients) + extract_emails(all_cc) + extract_emails(all_bcc)
262
+
263
+ try:
264
+ # 建立SMTP连接
265
+ if use_ssl:
266
+ server = smtplib.SMTP_SSL(smtp_server, port, timeout=timeout)
267
+ else:
268
+ server = smtplib.SMTP(smtp_server, port, timeout=timeout)
269
+ server.starttls()
270
+
271
+ # 登录并发送
272
+ server.login(email_account, password)
273
+ server.sendmail(email_account, all_emails, msg.as_string())
274
+ server.quit()
275
+
276
+ return {
277
+ "success": True,
278
+ "message": f"邮件发送成功,共发送给{len(all_emails)}个收件人",
279
+ "recipient_count": len(all_emails),
280
+ "smtp_server": smtp_server
281
+ }
282
+
283
+ except Exception as e:
284
+ return {
285
+ "success": False,
286
+ "message": f"邮件发送失败: {str(e)}",
287
+ "recipient_count": 0,
288
+ "smtp_server": smtp_server
289
+ }
290
+
291
+ def fetch_emails(
292
+ email_account: str,
293
+ password: str,
294
+ subject: Optional[str] = None,
295
+ sender: Optional[str] = None,
296
+ date_range: Optional[Tuple[datetime, datetime]] = None,
297
+ mailbox: str = 'INBOX',
298
+ download_attachments: bool = False,
299
+ attachment_dir: str = 'attachments',
300
+ max_emails: Optional[int] = None,
301
+ imap_config: Optional[Dict[str, Any]] = None,
302
+ search_mode: str = 'exact' # 'exact', 'fuzzy', 'regex'
303
+ ) -> Dict[str, Any]:
304
+ """
305
+ 简单易用的邮件获取函数(支持按主题、发件人搜索,附件下载等)
306
+
307
+ 使用示例:
308
+ # 基础用法 - 获取所有邮件
309
+ result = fetch_emails(
310
+ email_account="your@qq.com",
311
+ password="your_password",
312
+ max_emails=10
313
+ )
314
+
315
+ # 按主题搜索邮件
316
+ result = fetch_emails(
317
+ email_account="your@gmail.com",
318
+ password="app_password",
319
+ subject="项目报告",
320
+ search_mode="fuzzy",
321
+ date_range=(datetime(2024, 1, 1), datetime(2024, 12, 31))
322
+ )
323
+
324
+ # 下载附件
325
+ result = fetch_emails(
326
+ email_account="your@163.com",
327
+ password="auth_code",
328
+ sender="boss@company.com",
329
+ download_attachments=True,
330
+ attachment_dir="./downloads"
331
+ )
332
+
333
+ # 使用自定义IMAP配置
334
+ result = fetch_emails(
335
+ email_account="user@company.com",
336
+ password="password",
337
+ imap_config={"server": "imap.company.com", "port": 993, "use_ssl": True}
338
+ )
339
+
340
+ Args:
341
+ email_account: 邮箱账号
342
+ password: 邮箱密码或授权码
343
+ subject: 邮件主题关键词(可选)
344
+ sender: 发件人邮箱(可选)
345
+ date_range: 日期范围元组(start_date, end_date),默认最近7天
346
+ mailbox: 邮箱文件夹,默认'INBOX'
347
+ download_attachments: 是否下载附件,默认False
348
+ attachment_dir: 附件保存目录,默认'attachments'
349
+ max_emails: 最大返回邮件数量(可选)
350
+ imap_config: 自定义IMAP配置,格式: {"server": "imap.xxx.com", "port": 993, "use_ssl": True}
351
+ search_mode: 搜索模式: 'exact'(精确), 'fuzzy'(模糊), 'regex'(正则)
352
+
353
+ Returns:
354
+ Dict[str, Any]: 获取结果
355
+ {
356
+ "success": bool, # 是否成功
357
+ "message": str, # 结果消息
358
+ "email_count": int, # 获取的邮件数量
359
+ "emails": List[Dict], # 邮件列表
360
+ "attachments_dir": str # 附件保存目录
361
+ }
362
+
363
+ 邮件格式:
364
+ {
365
+ "subject": str, # 邮件主题
366
+ "from": str, # 发件人
367
+ "to": str, # 收件人
368
+ "date": str, # 发送日期
369
+ "text_body": str, # 纯文本正文
370
+ "html_body": str, # HTML正文
371
+ "attachments": List[Dict], # 附件列表
372
+ "size": int # 邮件大小(字节)
373
+ }
374
+ """
375
+ try:
376
+ # 设置默认日期范围
377
+ if date_range is None:
378
+ end_date = datetime.now()
379
+ start_date = end_date - timedelta(days=7)
380
+ date_range = (start_date, end_date)
381
+
382
+ # 创建附件目录
383
+ if download_attachments:
384
+ os.makedirs(attachment_dir, exist_ok=True)
385
+
386
+ # 自动配置IMAP服务器
387
+ domain = email_account.split("@")[-1].lower()
388
+ default_imap_config = {
389
+ "qq.com": {"server": "imap.qq.com", "port": 993, "use_ssl": True},
390
+ "gmail.com": {"server": "imap.gmail.com", "port": 993, "use_ssl": True},
391
+ "163.com": {"server": "imap.163.com", "port": 993, "use_ssl": True},
392
+ "126.com": {"server": "imap.126.com", "port": 993, "use_ssl": True},
393
+ "outlook.com": {"server": "imap-mail.outlook.com", "port": 993, "use_ssl": True},
394
+ "hotmail.com": {"server": "imap-mail.outlook.com", "port": 993, "use_ssl": True},
395
+ "aliyun.com": {"server": "imap.aliyun.com", "port": 993, "use_ssl": True},
396
+ "chinaott.net": {"server": "imap.exmail.qq.com", "port": 993, "use_ssl": True},
397
+ }
398
+
399
+ # 使用自定义配置或自动配置
400
+ if imap_config:
401
+ imap_server = imap_config.get("server")
402
+ port = imap_config.get("port", 993)
403
+ use_ssl = imap_config.get("use_ssl", True)
404
+ else:
405
+ if domain not in default_imap_config:
406
+ raise ValueError(f"不支持的邮箱服务商: {domain},请提供自定义imap_config")
407
+ config = default_imap_config[domain]
408
+ imap_server = config["server"]
409
+ port = config["port"]
410
+ use_ssl = config["use_ssl"]
411
+
412
+ # 连接IMAP服务器
413
+ if use_ssl:
414
+ mail = imaplib.IMAP4_SSL(imap_server, port)
415
+ else:
416
+ mail = imaplib.IMAP4(imap_server, port)
417
+
418
+ try:
419
+ mail.login(email_account, password)
420
+
421
+ # 选择邮箱文件夹
422
+ try:
423
+ mail.select(mailbox)
424
+ except:
425
+ # 如果指定文件夹不存在,使用INBOX
426
+ mail.select('INBOX')
427
+
428
+ # 构建搜索条件
429
+ search_criteria = []
430
+
431
+ # 日期范围
432
+ start_str = date_range[0].strftime("%d-%b-%Y")
433
+ end_str = date_range[1].strftime("%d-%b-%Y")
434
+ search_criteria.append(f'(SINCE "{start_str}" BEFORE "{end_str}")')
435
+
436
+ # 主题搜索
437
+ if subject:
438
+ if search_mode == 'exact':
439
+ search_criteria.append(f'(SUBJECT "{subject}")')
440
+ elif search_mode == 'fuzzy':
441
+ search_criteria.append(f'(SUBJECT "{subject}")') # IMAP原生支持部分匹配
442
+ elif search_mode == 'regex':
443
+ # 正则搜索需要在获取后处理
444
+ search_criteria.append(f'(SUBJECT "{subject}")')
445
+
446
+ # 发件人搜索
447
+ if sender:
448
+ search_criteria.append(f'(FROM "{sender}")')
449
+
450
+ # 组合搜索条件
451
+ if len(search_criteria) > 1:
452
+ search_query = ' '.join(search_criteria)
453
+ else:
454
+ search_query = search_criteria[0] if search_criteria else 'ALL'
455
+
456
+ # 搜索邮件
457
+ status, messages = mail.search(None, search_query)
458
+ if status != 'OK' or not messages[0]:
459
+ return {
460
+ "success": True,
461
+ "message": "没有找到匹配的邮件",
462
+ "email_count": 0,
463
+ "emails": [],
464
+ "attachments_dir": attachment_dir if download_attachments else None
465
+ }
466
+
467
+ mail_ids = messages[0].split()
468
+ if max_emails:
469
+ mail_ids = mail_ids[-max_emails:] # 获取最新的邮件
470
+
471
+ emails = []
472
+ for mail_id in reversed(mail_ids): # 从新到旧排序
473
+ try:
474
+ status, data = mail.fetch(mail_id, '(RFC822)')
475
+ if status != 'OK':
476
+ continue
477
+
478
+ msg = email.message_from_bytes(data[0][1])
479
+
480
+ # 解码邮件主题
481
+ subject_header = decode_header(msg.get('Subject', ''))
482
+ subject_str = ""
483
+ for part, encoding in subject_header:
484
+ if isinstance(part, bytes):
485
+ try:
486
+ subject_str += part.decode(encoding or 'utf-8', errors='replace')
487
+ except:
488
+ subject_str += part.decode('gbk', errors='replace')
489
+ else:
490
+ subject_str += str(part)
491
+
492
+ # 检查主题匹配(对于正则模式进行二次过滤)
493
+ if subject and search_mode == 'regex':
494
+ import re
495
+ if not re.search(subject, subject_str, re.IGNORECASE):
496
+ continue
497
+ elif subject and search_mode == 'fuzzy':
498
+ if subject.lower() not in subject_str.lower():
499
+ continue
500
+
501
+ # 提取正文内容
502
+ text_body = ""
503
+ html_body = ""
504
+ attachments_list = []
505
+ total_size = 0
506
+
507
+ if msg.is_multipart():
508
+ for part in msg.walk():
509
+ content_type = part.get_content_type()
510
+ content_disposition = str(part.get("Content-Disposition"))
511
+
512
+ # 获取邮件大小
513
+ if part.get('Content-Length'):
514
+ try:
515
+ total_size += int(part.get('Content-Length'))
516
+ except:
517
+ pass
518
+
519
+ # 处理正文
520
+ if "attachment" not in content_disposition:
521
+ try:
522
+ if content_type == "text/plain":
523
+ text_body += part.get_payload(decode=True).decode(
524
+ part.get_content_charset() or 'utf-8', errors='replace'
525
+ )
526
+ elif content_type == "text/html":
527
+ html_body += part.get_payload(decode=True).decode(
528
+ part.get_content_charset() or 'utf-8', errors='replace'
529
+ )
530
+ except:
531
+ pass
532
+
533
+ # 处理附件
534
+ elif download_attachments and part.get_filename():
535
+ try:
536
+ filename = decode_header(part.get_filename())[0][0]
537
+ if isinstance(filename, bytes):
538
+ filename = filename.decode('utf-8', errors='replace')
539
+
540
+ filepath = os.path.join(attachment_dir, filename)
541
+ with open(filepath, 'wb') as f:
542
+ f.write(part.get_payload(decode=True))
543
+
544
+ attachments_list.append({
545
+ 'filename': filename,
546
+ 'filepath': os.path.abspath(filepath),
547
+ 'size': len(part.get_payload(decode=True))
548
+ })
549
+ except Exception as e:
550
+ print(f"处理附件失败: {e}")
551
+ else:
552
+ # 单部分邮件
553
+ try:
554
+ text_body = msg.get_payload(decode=True).decode(
555
+ msg.get_content_charset() or 'utf-8', errors='replace'
556
+ )
557
+ total_size = len(msg.get_payload(decode=True))
558
+ except:
559
+ pass
560
+
561
+ emails.append({
562
+ 'subject': subject_str,
563
+ 'from': msg.get('From', ''),
564
+ 'to': msg.get('To', ''),
565
+ 'date': msg.get('Date', ''),
566
+ 'text_body': text_body.strip(),
567
+ 'html_body': html_body.strip(),
568
+ 'attachments': attachments_list,
569
+ 'size': total_size
570
+ })
571
+
572
+ except Exception as e:
573
+ print(f"处理邮件 {mail_id} 失败: {e}")
574
+ continue
575
+
576
+ mail.close()
577
+ mail.logout()
578
+
579
+ return {
580
+ "success": True,
581
+ "message": f"成功获取 {len(emails)} 封邮件",
582
+ "email_count": len(emails),
583
+ "emails": emails,
584
+ "attachments_dir": attachment_dir if download_attachments else None
585
+ }
586
+
587
+ except Exception as e:
588
+ mail.logout()
589
+ return {
590
+ "success": False,
591
+ "message": f"邮件获取失败: {str(e)}",
592
+ "email_count": 0,
593
+ "emails": [],
594
+ "attachments_dir": None
595
+ }
596
+
597
+ except Exception as e:
598
+ return {
599
+ "success": False,
600
+ "message": f"连接失败: {str(e)}",
601
+ "email_count": 0,
602
+ "emails": [],
603
+ "attachments_dir": None
604
+ }
605
+
606
+ # 别名 - 与pytoolsz的相关函数兼容
607
+ def quicksendemail(*args, **kwargs):
608
+ """兼容旧版本的send_email函数别名"""
609
+ return send_email(*args, **kwargs)
610
+
611
+ def quickemail(*args, **kwargs):
612
+ """兼容旧版本的send_email函数别名"""
613
+ return send_email(*args, **kwargs)
614
+
615
+ def load_email_by_subject(*args, **kwargs):
616
+ """兼容旧版本的fetch_emails函数别名"""
617
+ return fetch_emails(*args, **kwargs)
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.3
2
+ Name: simtoolsz
3
+ Version: 0.1.0
4
+ Summary: A simple tool collection.
5
+ Author-email: Sidney Zhang <liangyi@me.com>
6
+ License: MulanPSL-2.0
7
+ Keywords: collection,tool
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+
11
+ # simtoolsz
12
+
13
+ [English](README_EN.md) | 中文
14
+
15
+
16
+ 一个简单、方便的工具集合,包含一些好用的函数、类、方法。
17
+
18
+ 计划把我之前写的[工具包](https://github.com/SidneyLYZhang/pytoolsz)做一些精简,之前的包被我塞了太多的东西。
19
+ 现在做一些精简,保留最常用的哪些工具,以及一些常用的函数。
20
+
21
+
@@ -0,0 +1,6 @@
1
+ simtoolsz/__init__.py,sha256=8JNMvp1ywrOzPBCYZB3HOFTSI32dqCeBz_F1M8VQumg,228
2
+ simtoolsz/mail.py,sha256=ckuuVRnf1uiBoIkNBF-jlF2KDgjWcPQ8PDNYSlp7CHk,25980
3
+ simtoolsz-0.1.0.dist-info/METADATA,sha256=kbHN-sfTR9xdaSGFnz-xGwnItdvVRWVkXLeFXFtnPsU,608
4
+ simtoolsz-0.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
5
+ simtoolsz-0.1.0.dist-info/licenses/LICENSE,sha256=sA6brmjrbeBVwOqDULJ--zt6qusnn7I8VC0T9BTU7D0,9311
6
+ simtoolsz-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.26.3
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,134 @@
1
+ 木兰宽松许可证, 第2版
2
+
3
+ 木兰宽松许可证, 第2版
4
+
5
+ 2020年1月 http://license.coscl.org.cn/MulanPSL2
6
+
7
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
8
+
9
+ 0. 定义
10
+
11
+ “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
12
+
13
+ “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
14
+
15
+ “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
16
+
17
+ “法人实体” 是指提交贡献的机构及其“关联实体”。
18
+
19
+ “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
20
+
21
+ 1. 授予版权许可
22
+
23
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
24
+
25
+ 2. 授予专利许可
26
+
27
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
28
+
29
+ 3. 无商标许可
30
+
31
+ “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
32
+
33
+ 4. 分发限制
34
+
35
+ 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
36
+
37
+ 5. 免责声明与责任限制
38
+
39
+ “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
40
+
41
+ 6. 语言
42
+
43
+ “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
44
+
45
+ 条款结束
46
+
47
+ 如何将木兰宽松许可证,第2版,应用到您的软件
48
+
49
+ 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
50
+
51
+ 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
52
+
53
+ 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
54
+
55
+ 3, 请将如下声明文本放入每个源文件的头部注释中。
56
+
57
+ Copyright (c) 2025 Sidney Zhang
58
+ simtoolsz is licensed under Mulan PSL v2.
59
+
60
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
61
+ You may obtain a copy of Mulan PSL v2 at:
62
+ http://license.coscl.org.cn/MulanPSL2
63
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
64
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
65
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
66
+ See the Mulan PSL v2 for more details.
67
+
68
+
69
+ Mulan Permissive Software License,Version 2
70
+
71
+ Mulan Permissive Software License,Version 2 (Mulan PSL v2)
72
+
73
+ January 2020 http://license.coscl.org.cn/MulanPSL2
74
+
75
+ Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
76
+
77
+ 0. Definition
78
+
79
+ Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
80
+
81
+ Contribution means the copyrightable work licensed by a particular Contributor under this License.
82
+
83
+ Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
84
+
85
+ Legal Entity means the entity making a Contribution and all its Affiliates.
86
+
87
+ Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
88
+
89
+ 1. Grant of Copyright License
90
+
91
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
92
+
93
+ 2. Grant of Patent License
94
+
95
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
96
+
97
+ 3. No Trademark License
98
+
99
+ No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
100
+
101
+ 4. Distribution Restriction
102
+
103
+ You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
104
+
105
+ 5. Disclaimer of Warranty and Limitation of Liability
106
+
107
+ THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
108
+
109
+ 6. Language
110
+
111
+ THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
112
+
113
+ END OF THE TERMS AND CONDITIONS
114
+
115
+ How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
116
+
117
+ To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
118
+
119
+ Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
120
+
121
+ Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
122
+
123
+ Attach the statement to the appropriate annotated syntax at the beginning of each source file.
124
+
125
+ Copyright (c) 2025 Sidney Zhang
126
+ simtoolsz is licensed under Mulan PSL v2.
127
+
128
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
129
+ You may obtain a copy of Mulan PSL v2 at:
130
+ http://license.coscl.org.cn/MulanPSL2
131
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
132
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
133
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
134
+ See the Mulan PSL v2 for more details.