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