xenoslib 0.1.29.13__tar.gz → 0.1.29.14__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.
Files changed (22) hide show
  1. {xenoslib-0.1.29.13/xenoslib.egg-info → xenoslib-0.1.29.14}/PKG-INFO +1 -1
  2. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/about.py +1 -1
  3. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/mail.py +27 -16
  4. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14/xenoslib.egg-info}/PKG-INFO +1 -1
  5. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/LICENSE +0 -0
  6. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/README.md +0 -0
  7. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/setup.cfg +0 -0
  8. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/setup.py +0 -0
  9. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/__init__.py +0 -0
  10. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/__main__.py +0 -0
  11. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/base.py +0 -0
  12. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/dev.py +0 -0
  13. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/extend.py +0 -0
  14. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/linux.py +0 -0
  15. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/mock.py +0 -0
  16. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/onedrive.py +0 -0
  17. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/win_trayicon.py +0 -0
  18. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib/windows.py +0 -0
  19. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib.egg-info/SOURCES.txt +0 -0
  20. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib.egg-info/dependency_links.txt +0 -0
  21. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib.egg-info/requires.txt +0 -0
  22. {xenoslib-0.1.29.13 → xenoslib-0.1.29.14}/xenoslib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xenoslib
3
- Version: 0.1.29.13
3
+ Version: 0.1.29.14
4
4
  Summary: Xenos' common lib
5
5
  Home-page: https://github.com/XenosLu/xenoslib.git
6
6
  Author: Xenocider
@@ -4,4 +4,4 @@ __url__ = "https://github.com/XenosLu/xenoslib.git"
4
4
  __author__ = "Xenocider"
5
5
  __author_email__ = "xenos.lu@gmail.com"
6
6
  __license__ = "MIT License"
7
- __version__ = "0.1.29.13"
7
+ __version__ = "0.1.29.14"
@@ -127,24 +127,19 @@ class SMTPMail:
127
127
  receivers.append(receiver)
128
128
  elif isinstance(receiver, (list, tuple)):
129
129
  receivers.extend(receiver)
130
- msg = MIMEMultipart()
131
- msg["Subject"] = Header(subject, "utf-8")
132
- msg["From"] = Header(self.sender, "utf-8")
133
- msg["To"] = ";".join(receivers)
130
+ msg = self.construct_msg(
131
+ subject=subject,
132
+ message=message,
133
+ receivers=receivers,
134
+ cc=cc,
135
+ filename=filename,
136
+ )
134
137
  if cc:
135
138
  msg["Cc"] = ";".join(cc)
136
139
  receivers.extend(cc)
137
140
  if bcc:
138
141
  receivers.extend(bcc)
139
- msg["Message-ID"] = make_msgid()
140
- msg.attach(MIMEText(message, "html", "utf-8"))
141
- if filename:
142
- attachment = MIMEApplication(open(filename, "rb").read())
143
- attachment.add_header("Content-Disposition", "attachment", filename=filename)
144
- msg.attach(attachment)
145
-
146
142
  with self.SMTP(self.smtp_server, self.port) as smtp:
147
- print(smtp.has_extn("STARTTLS"))
148
143
  if smtp.has_extn("STARTTLS"):
149
144
  smtp.starttls()
150
145
  try:
@@ -155,6 +150,19 @@ class SMTPMail:
155
150
  smtp.sendmail(self.sender, receivers, msg.as_string())
156
151
  return True
157
152
 
153
+ def construct_msg(self, subject, message, receivers=None, cc=None, filename=None):
154
+ msg = MIMEMultipart()
155
+ msg["Subject"] = Header(subject, "utf-8")
156
+ msg["From"] = Header(self.sender, "utf-8")
157
+ msg["To"] = ";".join(receivers)
158
+ msg["Message-ID"] = make_msgid()
159
+ msg.attach(MIMEText(message, "html", "utf-8"))
160
+ if filename:
161
+ attachment = MIMEApplication(open(filename, "rb").read())
162
+ attachment.add_header("Content-Disposition", "attachment", filename=filename)
163
+ msg.attach(attachment)
164
+ return msg
165
+
158
166
 
159
167
  def test_imap():
160
168
  try:
@@ -173,7 +181,7 @@ def test_imap():
173
181
  # ~ print(email_data.keys())
174
182
 
175
183
 
176
- def test():
184
+ def test_smtp():
177
185
  try:
178
186
  import env # noqa
179
187
  except ModuleNotFoundError:
@@ -185,9 +193,12 @@ def test():
185
193
  message = '<span style="color:red">This is a test email.</span>'
186
194
  email_sender = SMTPMail(smtp_server, sender=mail_addr, password=mail_pwd, port=465)
187
195
  # email_sender = SMTPMail(smtp_server, sender=mail_addr, password=mail_pwd, port=587)
188
- email_sender.send(subject=subject, message=message, receiver=os.environ["RECEIVER"])
196
+ # ~ email_sender.send(subject=subject, message=message, receiver=os.environ["RECEIVER"],bcc=["haiwe.lu@sap.com"])
197
+ email_sender.send(
198
+ subject=subject, message=message, receiver="luhw@cndatacom.com", bcc=["haiwei.lu@sap.com"]
199
+ )
189
200
 
190
201
 
191
202
  if __name__ == "__main__":
192
- test_imap()
193
- # ~ test()
203
+ # ~ test_imap()
204
+ test_smtp()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xenoslib
3
- Version: 0.1.29.13
3
+ Version: 0.1.29.14
4
4
  Summary: Xenos' common lib
5
5
  Home-page: https://github.com/XenosLu/xenoslib.git
6
6
  Author: Xenocider
File without changes
File without changes
File without changes
File without changes