envelope 2.0.3__tar.gz → 2.0.4__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.
- {envelope-2.0.3 → envelope-2.0.4}/PKG-INFO +5 -11
- {envelope-2.0.3 → envelope-2.0.4}/README.md +3 -3
- {envelope-2.0.3 → envelope-2.0.4}/envelope/envelope.py +3 -3
- {envelope-2.0.3 → envelope-2.0.4}/envelope/smtp_handler.py +2 -2
- {envelope-2.0.3 → envelope-2.0.4}/envelope/utils.py +6 -2
- {envelope-2.0.3 → envelope-2.0.4}/envelope.egg-info/PKG-INFO +5 -11
- {envelope-2.0.3 → envelope-2.0.4}/setup.py +1 -1
- {envelope-2.0.3 → envelope-2.0.4}/LICENSE.txt +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/__init__.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/__main__.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/address.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/attachment.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/constants.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/message.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope/parser.py +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope.egg-info/SOURCES.txt +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope.egg-info/dependency_links.txt +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope.egg-info/entry_points.txt +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/envelope.egg-info/requires.txt +1 -1
- {envelope-2.0.3 → envelope-2.0.4}/envelope.egg-info/top_level.txt +0 -0
- {envelope-2.0.3 → envelope-2.0.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: envelope
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Insert a message and attachments and send e-mail / sign / encrypt contents by a single line.
|
|
5
5
|
Home-page: https://github.com/CZ-NIC/envelope
|
|
6
6
|
Author: Edvard Rejthar
|
|
@@ -9,14 +9,8 @@ License: GNU GPLv3
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Python: >=3.10
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE.txt
|
|
13
|
-
Requires-Dist: jsonpickle
|
|
14
|
-
Requires-Dist: python-magic
|
|
15
|
-
Requires-Dist: python-gnupg>=0.5
|
|
16
|
-
Requires-Dist: py3-validate-email; python_version >= "3.8"
|
|
17
|
-
Requires-Dist: py3-validate-email<1.0.6; python_version < "3.8"
|
|
18
12
|
Provides-Extra: smime
|
|
19
|
-
|
|
13
|
+
License-File: LICENSE.txt
|
|
20
14
|
|
|
21
15
|
# Envelope
|
|
22
16
|
|
|
@@ -100,7 +94,7 @@ Envelope.load(path="message.eml").attachments()
|
|
|
100
94
|
* If planning to use S/MIME, you should ensure some prerequisites: `sudo apt install swig build-essential python3-dev libssl-dev && pip3 install M2Crypto`
|
|
101
95
|
* If planning to send e-mails, prepare SMTP credentials or visit [Configure your SMTP](#configure-your-smtp) tutorial.
|
|
102
96
|
* If your e-mails are to be received outside your local domain, visit [DMARC](#dmarc) section.
|
|
103
|
-
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects.
|
|
97
|
+
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects. Both use `libmagic` under the hood which is probably already installed. However, if it is not, [install](https://github.com/ahupp/python-magic?tab=readme-ov-file#installation) `sudo apt install libmagic1`.
|
|
104
98
|
|
|
105
99
|
## Bash completion
|
|
106
100
|
1. Run: `apt install bash-completion jq`
|
|
@@ -358,7 +352,7 @@ Envelope().attach(path="file.jpg")
|
|
|
358
352
|
* **attachments**
|
|
359
353
|
* **--attach**: Path to the attachment, followed by optional file name to be used and/or mime type. This parameter may be used multiple times.
|
|
360
354
|
```bash
|
|
361
|
-
envelope --
|
|
355
|
+
envelope --attach "/tmp/file.txt" "displayed-name.txt" "text/plain" --attach "/tmp/another-file.txt"
|
|
362
356
|
```
|
|
363
357
|
* **.attach(attachment=, mimetype=, name=, path=, inline=)**:
|
|
364
358
|
```python3
|
|
@@ -385,7 +379,7 @@ Envelope().attach(path="file.jpg")
|
|
|
385
379
|
```
|
|
386
380
|
* **mime**: Sets contents mime subtype: "**auto**" (default), "**html**" or "**plain**" for plain text.
|
|
387
381
|
Maintype is always set to "text".
|
|
388
|
-
|
|
382
|
+
If a line is longer than 1000 characters, makes the message be transferred safely by bytes (otherwise these non-standard long lines might cause a transferring SMTP server to include line breaks and redundant spaces that might break up ex: DKIM signature).
|
|
389
383
|
In case of `Content-Type` header put to the message, **mime** section functionality **is skipped**.
|
|
390
384
|
* **--mime SUBTYPE**
|
|
391
385
|
* **.mime(subtype="auto", nl2br="auto")**
|
|
@@ -80,7 +80,7 @@ Envelope.load(path="message.eml").attachments()
|
|
|
80
80
|
* If planning to use S/MIME, you should ensure some prerequisites: `sudo apt install swig build-essential python3-dev libssl-dev && pip3 install M2Crypto`
|
|
81
81
|
* If planning to send e-mails, prepare SMTP credentials or visit [Configure your SMTP](#configure-your-smtp) tutorial.
|
|
82
82
|
* If your e-mails are to be received outside your local domain, visit [DMARC](#dmarc) section.
|
|
83
|
-
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects.
|
|
83
|
+
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects. Both use `libmagic` under the hood which is probably already installed. However, if it is not, [install](https://github.com/ahupp/python-magic?tab=readme-ov-file#installation) `sudo apt install libmagic1`.
|
|
84
84
|
|
|
85
85
|
## Bash completion
|
|
86
86
|
1. Run: `apt install bash-completion jq`
|
|
@@ -338,7 +338,7 @@ Envelope().attach(path="file.jpg")
|
|
|
338
338
|
* **attachments**
|
|
339
339
|
* **--attach**: Path to the attachment, followed by optional file name to be used and/or mime type. This parameter may be used multiple times.
|
|
340
340
|
```bash
|
|
341
|
-
envelope --
|
|
341
|
+
envelope --attach "/tmp/file.txt" "displayed-name.txt" "text/plain" --attach "/tmp/another-file.txt"
|
|
342
342
|
```
|
|
343
343
|
* **.attach(attachment=, mimetype=, name=, path=, inline=)**:
|
|
344
344
|
```python3
|
|
@@ -365,7 +365,7 @@ Envelope().attach(path="file.jpg")
|
|
|
365
365
|
```
|
|
366
366
|
* **mime**: Sets contents mime subtype: "**auto**" (default), "**html**" or "**plain**" for plain text.
|
|
367
367
|
Maintype is always set to "text".
|
|
368
|
-
|
|
368
|
+
If a line is longer than 1000 characters, makes the message be transferred safely by bytes (otherwise these non-standard long lines might cause a transferring SMTP server to include line breaks and redundant spaces that might break up ex: DKIM signature).
|
|
369
369
|
In case of `Content-Type` header put to the message, **mime** section functionality **is skipped**.
|
|
370
370
|
* **--mime SUBTYPE**
|
|
371
371
|
* **.mime(subtype="auto", nl2br="auto")**
|
|
@@ -24,7 +24,7 @@ from os import environ
|
|
|
24
24
|
from pathlib import Path
|
|
25
25
|
from quopri import decodestring
|
|
26
26
|
from types import GeneratorType
|
|
27
|
-
from typing import Union, List, Set, Optional, Any
|
|
27
|
+
from typing import Literal, Union, List, Set, Optional, Any
|
|
28
28
|
|
|
29
29
|
from .address import Address
|
|
30
30
|
from .attachment import Attachment
|
|
@@ -584,7 +584,7 @@ class Envelope:
|
|
|
584
584
|
self._subject_encrypted = encrypted
|
|
585
585
|
return self
|
|
586
586
|
|
|
587
|
-
def mime(self, subtype=AUTO, nl2br=AUTO):
|
|
587
|
+
def mime(self, subtype=AUTO, nl2br: Literal["auto"] | bool=AUTO):
|
|
588
588
|
"""
|
|
589
589
|
Ignored if `Content-Type` header put to the message.
|
|
590
590
|
@type subtype: str Set contents mime subtype: "auto" (default), "html" or "plain" for plain text.
|
|
@@ -951,7 +951,7 @@ class Envelope:
|
|
|
951
951
|
|
|
952
952
|
# if we plan to send later, convert text message to the email message object
|
|
953
953
|
email: Optional[Union[str, EmailMessage, Message]] = None
|
|
954
|
-
if send is not None or html: # `html` means the user
|
|
954
|
+
if send is not None or html or self._attachments: # `html` or attachments means the user needs a 'multipart/...' e-mail message
|
|
955
955
|
email = self._prepare_email(plain, html, encrypt and gpg_on, sign and gpg_on, sign)
|
|
956
956
|
if not email:
|
|
957
957
|
return
|
|
@@ -79,9 +79,9 @@ class SMTPHandler:
|
|
|
79
79
|
except (timeout_exc, SMTPException) as e:
|
|
80
80
|
# this connection is gone, reconnect next time
|
|
81
81
|
del self._instances[self.key]
|
|
82
|
-
if isinstance(e,
|
|
82
|
+
if isinstance(e, SMTPAuthenticationError):
|
|
83
83
|
logger.warning(
|
|
84
|
-
f"SMTP
|
|
84
|
+
f"SMTP authentication error, will not re-try. {e}")
|
|
85
85
|
return False
|
|
86
86
|
elif isinstance(e, timeout_exc):
|
|
87
87
|
if self.delay:
|
|
@@ -3,7 +3,10 @@ from io import TextIOBase, BufferedIOBase
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import TYPE_CHECKING, Iterable
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
try:
|
|
7
|
+
import magic
|
|
8
|
+
except ImportError as e:
|
|
9
|
+
magic = e
|
|
7
10
|
|
|
8
11
|
if TYPE_CHECKING:
|
|
9
12
|
from .envelope import Envelope
|
|
@@ -48,7 +51,8 @@ def get_mimetype(data: bytes = None, path: Path = None):
|
|
|
48
51
|
""" We support both python-magic and file-magic library, any of them can be on the system. #25
|
|
49
52
|
Their funcionality is the same, their API differs.
|
|
50
53
|
"""
|
|
51
|
-
#
|
|
54
|
+
if isinstance(magic, ImportError): # user has to install libmagic
|
|
55
|
+
raise magic
|
|
52
56
|
if hasattr(magic.Magic, "from_file"): # this is python-magic
|
|
53
57
|
if data:
|
|
54
58
|
return magic.Magic(mime=True).from_buffer(data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: envelope
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.4
|
|
4
4
|
Summary: Insert a message and attachments and send e-mail / sign / encrypt contents by a single line.
|
|
5
5
|
Home-page: https://github.com/CZ-NIC/envelope
|
|
6
6
|
Author: Edvard Rejthar
|
|
@@ -9,14 +9,8 @@ License: GNU GPLv3
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Python: >=3.10
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE.txt
|
|
13
|
-
Requires-Dist: jsonpickle
|
|
14
|
-
Requires-Dist: python-magic
|
|
15
|
-
Requires-Dist: python-gnupg>=0.5
|
|
16
|
-
Requires-Dist: py3-validate-email; python_version >= "3.8"
|
|
17
|
-
Requires-Dist: py3-validate-email<1.0.6; python_version < "3.8"
|
|
18
12
|
Provides-Extra: smime
|
|
19
|
-
|
|
13
|
+
License-File: LICENSE.txt
|
|
20
14
|
|
|
21
15
|
# Envelope
|
|
22
16
|
|
|
@@ -100,7 +94,7 @@ Envelope.load(path="message.eml").attachments()
|
|
|
100
94
|
* If planning to use S/MIME, you should ensure some prerequisites: `sudo apt install swig build-essential python3-dev libssl-dev && pip3 install M2Crypto`
|
|
101
95
|
* If planning to send e-mails, prepare SMTP credentials or visit [Configure your SMTP](#configure-your-smtp) tutorial.
|
|
102
96
|
* If your e-mails are to be received outside your local domain, visit [DMARC](#dmarc) section.
|
|
103
|
-
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects.
|
|
97
|
+
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects. Both use `libmagic` under the hood which is probably already installed. However, if it is not, [install](https://github.com/ahupp/python-magic?tab=readme-ov-file#installation) `sudo apt install libmagic1`.
|
|
104
98
|
|
|
105
99
|
## Bash completion
|
|
106
100
|
1. Run: `apt install bash-completion jq`
|
|
@@ -358,7 +352,7 @@ Envelope().attach(path="file.jpg")
|
|
|
358
352
|
* **attachments**
|
|
359
353
|
* **--attach**: Path to the attachment, followed by optional file name to be used and/or mime type. This parameter may be used multiple times.
|
|
360
354
|
```bash
|
|
361
|
-
envelope --
|
|
355
|
+
envelope --attach "/tmp/file.txt" "displayed-name.txt" "text/plain" --attach "/tmp/another-file.txt"
|
|
362
356
|
```
|
|
363
357
|
* **.attach(attachment=, mimetype=, name=, path=, inline=)**:
|
|
364
358
|
```python3
|
|
@@ -385,7 +379,7 @@ Envelope().attach(path="file.jpg")
|
|
|
385
379
|
```
|
|
386
380
|
* **mime**: Sets contents mime subtype: "**auto**" (default), "**html**" or "**plain**" for plain text.
|
|
387
381
|
Maintype is always set to "text".
|
|
388
|
-
|
|
382
|
+
If a line is longer than 1000 characters, makes the message be transferred safely by bytes (otherwise these non-standard long lines might cause a transferring SMTP server to include line breaks and redundant spaces that might break up ex: DKIM signature).
|
|
389
383
|
In case of `Content-Type` header put to the message, **mime** section functionality **is skipped**.
|
|
390
384
|
* **--mime SUBTYPE**
|
|
391
385
|
* **.mime(subtype="auto", nl2br="auto")**
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|