UtilityLibAPI 1.2511.29__tar.gz → 1.2511.282__tar.gz
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.
- {utilitylibapi-1.2511.29/src/UtilityLibAPI.egg-info → utilitylibapi-1.2511.282}/PKG-INFO +1 -5
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/README.md +0 -4
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/pyproject.toml +1 -1
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI/MailSenderLib.py +21 -28
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282/src/UtilityLibAPI.egg-info}/PKG-INFO +1 -5
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/LICENSE +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/setup.cfg +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI/Archive7zLib.py +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI/EnDeCodeLib.py +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI/ExtWrapper7zLib.py +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI/SessionVARLib.py +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI/__init__.py +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/SOURCES.txt +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/dependency_links.txt +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/requires.txt +0 -0
- {utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: UtilityLibAPI
|
|
3
|
-
Version: 1.2511.
|
|
3
|
+
Version: 1.2511.282
|
|
4
4
|
Summary: UtilityLibAPI Python package
|
|
5
5
|
Author-email: James Lin <tylin123@ms27.hinet.net>
|
|
6
6
|
License: Copyright (c) 2025 James Lin **UtilityLibAPI**
|
|
@@ -33,10 +33,6 @@ Dynamic: license-file
|
|
|
33
33
|
#UtilityLibAPI Classes
|
|
34
34
|
|
|
35
35
|
## History of version
|
|
36
|
-
Version 1.2511.29: 2025/11/29<BR>
|
|
37
|
-
Fixed MailSenderLib: Attachement file name encode problem.
|
|
38
|
-
Add function for user can modify mail caption of from field.
|
|
39
|
-
|
|
40
36
|
Version 1.2511.282: 2025/11/27<BR>
|
|
41
37
|
Fixed MailSenderLib: Attachement file name encode problem.
|
|
42
38
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
#UtilityLibAPI Classes
|
|
2
2
|
|
|
3
3
|
## History of version
|
|
4
|
-
Version 1.2511.29: 2025/11/29<BR>
|
|
5
|
-
Fixed MailSenderLib: Attachement file name encode problem.
|
|
6
|
-
Add function for user can modify mail caption of from field.
|
|
7
|
-
|
|
8
4
|
Version 1.2511.282: 2025/11/27<BR>
|
|
9
5
|
Fixed MailSenderLib: Attachement file name encode problem.
|
|
10
6
|
|
|
@@ -2,10 +2,8 @@ import smtplib
|
|
|
2
2
|
from email.mime.text import MIMEText
|
|
3
3
|
from email.mime.multipart import MIMEMultipart
|
|
4
4
|
from email.mime.application import MIMEApplication
|
|
5
|
-
from email.mime.base import MIMEBase
|
|
6
5
|
from email.utils import formataddr
|
|
7
6
|
from email.header import Header
|
|
8
|
-
from email import encoders
|
|
9
7
|
from typing import List, Optional
|
|
10
8
|
import os
|
|
11
9
|
import mimetypes
|
|
@@ -26,10 +24,10 @@ class CLASS_MailSender:
|
|
|
26
24
|
:param Pmb_UseSSL: 是否使用 SSL 連線 (預設 True)
|
|
27
25
|
"""
|
|
28
26
|
self.Pms_SMTP_Server = Pms_SMTP_Server
|
|
29
|
-
self.Pmi_Port
|
|
30
|
-
self.Pms_Account
|
|
31
|
-
self.Pms_Password
|
|
32
|
-
self.Pmb_UseSSL
|
|
27
|
+
self.Pmi_Port = Pmi_Port
|
|
28
|
+
self.Pms_Account = Pms_Account
|
|
29
|
+
self.Pms_Password = Pms_Password
|
|
30
|
+
self.Pmb_UseSSL = Pmb_UseSSL
|
|
33
31
|
|
|
34
32
|
#------------------------------------------------------------
|
|
35
33
|
def CUF_CreateMessage(self,
|
|
@@ -42,14 +40,10 @@ class CLASS_MailSender:
|
|
|
42
40
|
Pobj_Bcc: Optional[List[str]] = None,
|
|
43
41
|
Pobj_Attachments: Optional[List[str]] = None) -> MIMEMultipart:
|
|
44
42
|
"""
|
|
45
|
-
建立郵件內容(支援 HTML /
|
|
43
|
+
建立郵件內容(支援 HTML / 附件)
|
|
46
44
|
"""
|
|
47
45
|
msg = MIMEMultipart("alternative")
|
|
48
|
-
|
|
49
|
-
# 設定寄件者別名
|
|
50
|
-
from_addr = formataddr((Pms_From or self.Pms_Account, self.Pms_Account))
|
|
51
|
-
msg["From"] = from_addr
|
|
52
|
-
|
|
46
|
+
msg["From"] = formataddr((Pms_From or self.Pms_Account, self.Pms_Account))
|
|
53
47
|
msg["To"] = ", ".join(Pobj_To or [])
|
|
54
48
|
if Pobj_Cc:
|
|
55
49
|
msg["Cc"] = ", ".join(Pobj_Cc)
|
|
@@ -62,7 +56,7 @@ class CLASS_MailSender:
|
|
|
62
56
|
if Pms_BodyHTML:
|
|
63
57
|
msg.attach(MIMEText(Pms_BodyHTML, "html", "utf-8"))
|
|
64
58
|
|
|
65
|
-
#
|
|
59
|
+
# 附件
|
|
66
60
|
if Pobj_Attachments:
|
|
67
61
|
for ms_path in Pobj_Attachments:
|
|
68
62
|
try:
|
|
@@ -92,6 +86,7 @@ class CLASS_MailSender:
|
|
|
92
86
|
msg.attach(part)
|
|
93
87
|
except Exception as e:
|
|
94
88
|
print(f"⚠️ Can not add attachment: {ms_path} ({e})")
|
|
89
|
+
|
|
95
90
|
return msg
|
|
96
91
|
|
|
97
92
|
#------------------------------------------------------------
|
|
@@ -100,18 +95,16 @@ class CLASS_MailSender:
|
|
|
100
95
|
Pms_BodyText: str,
|
|
101
96
|
Pms_BodyHTML: Optional[str],
|
|
102
97
|
Pobj_To: List[str],
|
|
103
|
-
Pms_From: Optional[str] = None,
|
|
104
98
|
Pobj_Cc: Optional[List[str]] = None,
|
|
105
99
|
Pobj_Bcc: Optional[List[str]] = None,
|
|
106
100
|
Pobj_Attachments: Optional[List[str]] = None) -> bool:
|
|
107
101
|
"""
|
|
108
|
-
|
|
102
|
+
實際寄送郵件
|
|
109
103
|
"""
|
|
110
104
|
msg = self.CUF_CreateMessage(
|
|
111
105
|
Pms_Subject=Pms_Subject,
|
|
112
106
|
Pms_BodyText=Pms_BodyText,
|
|
113
107
|
Pms_BodyHTML=Pms_BodyHTML,
|
|
114
|
-
Pms_From=Pms_From,
|
|
115
108
|
Pobj_To=Pobj_To,
|
|
116
109
|
Pobj_Cc=Pobj_Cc,
|
|
117
110
|
Pobj_Bcc=Pobj_Bcc,
|
|
@@ -119,19 +112,18 @@ class CLASS_MailSender:
|
|
|
119
112
|
)
|
|
120
113
|
|
|
121
114
|
all_recipients = (Pobj_To or []) + (Pobj_Cc or []) + (Pobj_Bcc or [])
|
|
122
|
-
from_addr = formataddr((Pms_From or self.Pms_Account, self.Pms_Account))
|
|
123
115
|
|
|
124
116
|
try:
|
|
125
117
|
if self.Pmb_UseSSL:
|
|
126
118
|
with smtplib.SMTP_SSL(self.Pms_SMTP_Server, self.Pmi_Port) as server:
|
|
127
119
|
server.login(self.Pms_Account, self.Pms_Password)
|
|
128
|
-
server.sendmail(
|
|
120
|
+
server.sendmail(self.Pms_Account, all_recipients, msg.as_string())
|
|
129
121
|
else:
|
|
130
122
|
with smtplib.SMTP(self.Pms_SMTP_Server, self.Pmi_Port) as server:
|
|
131
123
|
server.ehlo()
|
|
132
124
|
server.starttls()
|
|
133
125
|
server.login(self.Pms_Account, self.Pms_Password)
|
|
134
|
-
server.sendmail(
|
|
126
|
+
server.sendmail(self.Pms_Account, all_recipients, msg.as_string())
|
|
135
127
|
|
|
136
128
|
print("✅ Send Success!")
|
|
137
129
|
return True
|
|
@@ -139,6 +131,7 @@ class CLASS_MailSender:
|
|
|
139
131
|
print("❌ Failure:", e)
|
|
140
132
|
return False
|
|
141
133
|
|
|
134
|
+
|
|
142
135
|
# ================================================================================
|
|
143
136
|
# [範例]
|
|
144
137
|
# 匯入剛才寫好的 CLASS_MailSender
|
|
@@ -146,20 +139,20 @@ class CLASS_MailSender:
|
|
|
146
139
|
if __name__ == "__main__":
|
|
147
140
|
# === 初始化郵件傳送物件 ===
|
|
148
141
|
mailer = CLASS_MailSender(
|
|
149
|
-
Pms_SMTP_Server="msr.
|
|
142
|
+
Pms_SMTP_Server="msr.xxxx.net",
|
|
150
143
|
Pmi_Port=465,
|
|
151
|
-
Pms_Account="
|
|
152
|
-
Pms_Password="xxxxx",
|
|
144
|
+
Pms_Account="xxx.biz@xx.hxxxt.net",
|
|
145
|
+
Pms_Password="xxxxx*",
|
|
153
146
|
Pmb_UseSSL=True
|
|
154
147
|
)
|
|
155
148
|
|
|
156
149
|
# === 郵件收件者設定 ===
|
|
157
|
-
ml_To = ["
|
|
158
|
-
ml_Cc = ["
|
|
159
|
-
ml_Bcc = ["
|
|
150
|
+
ml_To = ["gt504@gxxxxxh.biz", "txxxxx@ms27.xxxt.net"]
|
|
151
|
+
ml_Cc = ["ebooxxx3@hotmail.com.tw"]
|
|
152
|
+
ml_Bcc = ["xxxxsty.lin@xxx.hinet.net"] # 密件副本,不會顯示在郵件中
|
|
160
153
|
|
|
161
154
|
# === 郵件主題與內容 ===
|
|
162
|
-
ms_Subject = "團隊週報通知
|
|
155
|
+
ms_Subject = "團隊週報通知"
|
|
163
156
|
|
|
164
157
|
ms_BodyText = """
|
|
165
158
|
這是一封自動寄出的團隊週報通知。
|
|
@@ -185,7 +178,8 @@ if __name__ == "__main__":
|
|
|
185
178
|
|
|
186
179
|
# === 附件路徑 ===
|
|
187
180
|
ml_Attachments = [
|
|
188
|
-
"X:\\TEMP\\
|
|
181
|
+
"X:\\TEMP\\BOOK\\RCR6000_匯出外部資料_RCR6000EXT_XXX.pdf",
|
|
182
|
+
"X:\\TEMP\\BOOK\\K9AKW4.jpg"
|
|
189
183
|
]
|
|
190
184
|
|
|
191
185
|
# === 寄送 ===
|
|
@@ -193,7 +187,6 @@ if __name__ == "__main__":
|
|
|
193
187
|
Pms_Subject=ms_Subject,
|
|
194
188
|
Pms_BodyText=ms_BodyText,
|
|
195
189
|
Pms_BodyHTML=ms_BodyHTML,
|
|
196
|
-
Pms_From = "太棒了!!abcdefg123",
|
|
197
190
|
Pobj_To=ml_To,
|
|
198
191
|
Pobj_Cc=ml_Cc,
|
|
199
192
|
Pobj_Bcc=ml_Bcc,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: UtilityLibAPI
|
|
3
|
-
Version: 1.2511.
|
|
3
|
+
Version: 1.2511.282
|
|
4
4
|
Summary: UtilityLibAPI Python package
|
|
5
5
|
Author-email: James Lin <tylin123@ms27.hinet.net>
|
|
6
6
|
License: Copyright (c) 2025 James Lin **UtilityLibAPI**
|
|
@@ -33,10 +33,6 @@ Dynamic: license-file
|
|
|
33
33
|
#UtilityLibAPI Classes
|
|
34
34
|
|
|
35
35
|
## History of version
|
|
36
|
-
Version 1.2511.29: 2025/11/29<BR>
|
|
37
|
-
Fixed MailSenderLib: Attachement file name encode problem.
|
|
38
|
-
Add function for user can modify mail caption of from field.
|
|
39
|
-
|
|
40
36
|
Version 1.2511.282: 2025/11/27<BR>
|
|
41
37
|
Fixed MailSenderLib: Attachement file name encode problem.
|
|
42
38
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/requires.txt
RENAMED
|
File without changes
|
{utilitylibapi-1.2511.29 → utilitylibapi-1.2511.282}/src/UtilityLibAPI.egg-info/top_level.txt
RENAMED
|
File without changes
|