mailsuite 2.3.0__tar.gz → 2.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: mailsuite
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: A Python package for retrieving, parsing, and sending emails
5
5
  Project-URL: Homepage, https://github.com/seanthegeek/mailsuite/
6
6
  Project-URL: Documentation, https://seanthegeek.net/mailsuite/
@@ -28,7 +28,7 @@ Requires-Dist: dkimpy>=1.1.0
28
28
  Requires-Dist: dnspython>=2.0.0
29
29
  Requires-Dist: expiringdict==1.2.2
30
30
  Requires-Dist: html2text>=2020.1.16
31
- Requires-Dist: imapclient>=3.1.0
31
+ Requires-Dist: imapclient>=4.0.0
32
32
  Requires-Dist: mail-parser>=4.6.2
33
33
  Requires-Dist: publicsuffix2>=2.20190812
34
34
  Provides-Extra: all
@@ -1,3 +1,3 @@
1
1
  """A Python package to simplify receiving, parsing, and sending email"""
2
2
 
3
- __version__ = "2.3.0"
3
+ __version__ = "2.3.2"
@@ -361,8 +361,10 @@ def parse_email(
361
361
 
362
362
  _parsed_email = mailparser.parse_from_string(data_str)
363
363
  parsed_email = _parsed_email.mail
364
- if isinstance(parsed_email, str):
365
- raise ValueError("Not an email") # noqa: TRY004
364
+ # mail-parser <=4.6.1 returns the input string for unparseable input;
365
+ # 4.6.2+ returns a dict with no headers instead.
366
+ if isinstance(parsed_email, str) or not _parsed_email.headers:
367
+ raise ValueError("Not an email")
366
368
  headers_str = re.split(r"(\n|\r\n){2,}", data_str)[0]
367
369
  parsed_email["raw_headers"] = headers_str
368
370
  headers_str = re.sub(r"(\n|\r\n)\s+", " ", headers_str)
@@ -400,7 +402,10 @@ def parse_email(
400
402
  parsed_email[header] = [parse_email_address(x) for x in email.utils.getaddresses([_headers[header]])]
401
403
  from_domain = None
402
404
  if "from" in parsed_email:
403
- if "domain" in parsed_email["from"]:
405
+ if (
406
+ parsed_email["from"] is not None
407
+ and "domain" in parsed_email["from"]
408
+ ):
404
409
  from_domain = parsed_email["from"]["domain"]
405
410
  else:
406
411
  logger.warning("Message from header could not be parsed")
@@ -39,7 +39,7 @@ dependencies = [
39
39
  "dnspython>=2.0.0",
40
40
  "expiringdict==1.2.2",
41
41
  "html2text>=2020.1.16",
42
- "IMAPClient>=3.1.0",
42
+ "IMAPClient>=4.0.0",
43
43
  "mail-parser>=4.6.2",
44
44
  "publicsuffix2>=2.20190812",
45
45
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes