mailadapter 0.1.0.dev1__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.
- mailadapter-0.1.0.dev1/.gitignore +38 -0
- mailadapter-0.1.0.dev1/CHANGELOG.md +0 -0
- mailadapter-0.1.0.dev1/CONTRIBUTING.md +14 -0
- mailadapter-0.1.0.dev1/LICENSE +21 -0
- mailadapter-0.1.0.dev1/PKG-INFO +266 -0
- mailadapter-0.1.0.dev1/README.md +248 -0
- mailadapter-0.1.0.dev1/SECURITY.md +26 -0
- mailadapter-0.1.0.dev1/docs/adr/0001-explicit-sync-async-interfaces.md +131 -0
- mailadapter-0.1.0.dev1/docs/layout.txt +67 -0
- mailadapter-0.1.0.dev1/pyproject.toml +32 -0
- mailadapter-0.1.0.dev1/src/mailadapter/__init__.py +43 -0
- mailadapter-0.1.0.dev1/src/mailadapter/exceptions.py +46 -0
- mailadapter-0.1.0.dev1/src/mailadapter/imap/__init__.py +0 -0
- mailadapter-0.1.0.dev1/src/mailadapter/imap/_base.py +92 -0
- mailadapter-0.1.0.dev1/src/mailadapter/imap/async_client.py +45 -0
- mailadapter-0.1.0.dev1/src/mailadapter/imap/client.py +46 -0
- mailadapter-0.1.0.dev1/src/mailadapter/imap/connection.py +129 -0
- mailadapter-0.1.0.dev1/src/mailadapter/imap/search.py +48 -0
- mailadapter-0.1.0.dev1/src/mailadapter/py.typed +0 -0
- mailadapter-0.1.0.dev1/src/mailadapter/servers.py +69 -0
- mailadapter-0.1.0.dev1/src/mailadapter/smtp/__init__.py +0 -0
- mailadapter-0.1.0.dev1/src/mailadapter/utils/__init__.py +0 -0
- mailadapter-0.1.0.dev1/src/mailadapter/utils/normalization.py +34 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
|
|
6
|
+
# Virtual environments
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
|
|
10
|
+
# Distribution artifacts
|
|
11
|
+
build/
|
|
12
|
+
dist/
|
|
13
|
+
|
|
14
|
+
# Testing and development
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.mypy_cache/
|
|
17
|
+
.ruff_cache/
|
|
18
|
+
.coverage
|
|
19
|
+
htmlcov/
|
|
20
|
+
|
|
21
|
+
# IDE
|
|
22
|
+
.idea/
|
|
23
|
+
.vscode/
|
|
24
|
+
|
|
25
|
+
# Credentials
|
|
26
|
+
.env
|
|
27
|
+
*.env
|
|
28
|
+
.env.*
|
|
29
|
+
!.env.example
|
|
30
|
+
.pypirc
|
|
31
|
+
secrets.py
|
|
32
|
+
|
|
33
|
+
# Local development scripts
|
|
34
|
+
ZZZ_*.py
|
|
35
|
+
|
|
36
|
+
# Operating system
|
|
37
|
+
.DS_Store
|
|
38
|
+
Thumbs.db
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
~ Write code that makes the next developer's job easier, not code that makes the current developer look smarter ~
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Design principles
|
|
7
|
+
- Prefer explicit implementations over implicit behavior.
|
|
8
|
+
- Prioritize readability and maintainability over minimizing lines of code.
|
|
9
|
+
- Centralize protocol and business logic while keeping public interfaces explicit.
|
|
10
|
+
- Avoid metaprogramming unless it provides a substantial architectural benefit.
|
|
11
|
+
- Maintain consistent synchronous and asynchronous APIs through automated testing.
|
|
12
|
+
- Introduce abstractions in response to concrete requirements rather than anticipated complexity.
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KarstCoding (https://karstcoding.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mailadapter
|
|
3
|
+
Version: 0.1.0.dev1
|
|
4
|
+
Summary: A lightweight, typed Python email client.
|
|
5
|
+
Project-URL: Homepage, https://karstcoding.com/open-source/mailadapter
|
|
6
|
+
Project-URL: Repository, https://github.com/KarstCoding/mailadapter
|
|
7
|
+
Project-URL: Issues, https://github.com/KarstCoding/mailadapter/issues
|
|
8
|
+
Author: KarstCoding
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: python-dateutil
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# MailAdapter
|
|
20
|
+
|
|
21
|
+
A lightweight, typed Python library for integrating email functionality into synchronous and asynchronous applications.
|
|
22
|
+
|
|
23
|
+
MailAdapter abstracts email protocol operations and connection management while maintaining explicit configuration and predictable execution behavior.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Synchronous and asynchronous IMAP clients.
|
|
28
|
+
- Email retrieval and composable search criteria.
|
|
29
|
+
- Automatic date normalization.
|
|
30
|
+
- Predefined and custom server configurations.
|
|
31
|
+
- Implicit TLS and STARTTLS support.
|
|
32
|
+
- Automatic connection lifecycle management.
|
|
33
|
+
- Structured exception handling.
|
|
34
|
+
- Strict, fail-fast connection establishment.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install mailadapter
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For development releases:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install --pre mailadapter
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Requires Python 3.11 or later.
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
### Synchronous Client
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import os
|
|
56
|
+
|
|
57
|
+
from mailadapter import IMAPClient, IMAPServers
|
|
58
|
+
|
|
59
|
+
client = IMAPClient(
|
|
60
|
+
server=IMAPServers.GMAIL,
|
|
61
|
+
username=os.environ["EMAIL_USERNAME"],
|
|
62
|
+
password=os.environ["EMAIL_PASSWORD"],
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
emails = client.fetch_all_emails()
|
|
66
|
+
|
|
67
|
+
for email in emails:
|
|
68
|
+
print(email["Subject"])
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Asynchronous Client
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import asyncio
|
|
75
|
+
import os
|
|
76
|
+
|
|
77
|
+
from mailadapter import AsyncIMAPClient, IMAPServers
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def main():
|
|
81
|
+
client = AsyncIMAPClient(
|
|
82
|
+
server=IMAPServers.GMAIL,
|
|
83
|
+
username=os.environ["EMAIL_USERNAME"],
|
|
84
|
+
password=os.environ["EMAIL_PASSWORD"],
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
emails = await client.fetch_all_emails()
|
|
88
|
+
|
|
89
|
+
for email in emails:
|
|
90
|
+
print(email["Subject"])
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
asyncio.run(main())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Asynchronous operations are thread-backed using `asyncio.to_thread()`. Cancellation does not terminate an already-running blocking operation.
|
|
97
|
+
|
|
98
|
+
## Email Retrieval
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
client.fetch_all_emails()
|
|
102
|
+
client.fetch_unread()
|
|
103
|
+
client.fetch_emails_by_sender("sender@example.com")
|
|
104
|
+
client.fetch_emails_by_date("2026-12-01")
|
|
105
|
+
|
|
106
|
+
client.fetch_emails_by_date_range(
|
|
107
|
+
start="2026-12-01",
|
|
108
|
+
end="2027-01-01",
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Multiple search criteria can be combined:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from mailadapter import SearchCriteria
|
|
116
|
+
|
|
117
|
+
emails = client.fetch(
|
|
118
|
+
SearchCriteria(
|
|
119
|
+
sender="sender@example.com",
|
|
120
|
+
subject="Invoice",
|
|
121
|
+
since="2026-12-01",
|
|
122
|
+
unread=True,
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Fetched messages are returned as standard-library `EmailMessage` objects. Retrieval does not mark messages as read.
|
|
128
|
+
|
|
129
|
+
Date filters accept strings, `date` and `datetime` objects. Date ranges are start-inclusive and end-exclusive. ISO 8601 date strings are recommended.
|
|
130
|
+
|
|
131
|
+
## Server Configuration
|
|
132
|
+
|
|
133
|
+
MailAdapter includes presets for common email providers, including Gmail, Outlook, Microsoft 365, Yahoo, iCloud, GMX and others.
|
|
134
|
+
|
|
135
|
+
Custom servers can be configured explicitly:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from mailadapter import ServerConfig, TLSMode
|
|
139
|
+
|
|
140
|
+
server = ServerConfig(
|
|
141
|
+
host="mail.example.com",
|
|
142
|
+
port=993,
|
|
143
|
+
tls=TLSMode.IMPLICIT,
|
|
144
|
+
)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Supported encryption modes:
|
|
148
|
+
|
|
149
|
+
| Mode | Description |
|
|
150
|
+
|---|---|
|
|
151
|
+
| `TLSMode.IMPLICIT` | TLS encryption from connection establishment. |
|
|
152
|
+
| `TLSMode.STARTTLS` | Explicit TLS upgrade before authentication. |
|
|
153
|
+
|
|
154
|
+
Some providers require application-specific passwords or OAuth2. The current implementation supports username-and-password authentication.
|
|
155
|
+
|
|
156
|
+
## Connection Policy
|
|
157
|
+
|
|
158
|
+
MailAdapter follows a strict, fail-fast connection policy.
|
|
159
|
+
|
|
160
|
+
Connections are established exclusively according to the supplied configuration. The library does not perform:
|
|
161
|
+
|
|
162
|
+
- Automatic server or port discovery.
|
|
163
|
+
- Fallback to alternative connection settings.
|
|
164
|
+
- Fallback between TLS modes.
|
|
165
|
+
- Fallback to unencrypted connections.
|
|
166
|
+
- Automatic authentication strategy switching.
|
|
167
|
+
- Automatic connection retries.
|
|
168
|
+
|
|
169
|
+
Failed operations raise exceptions rather than silently attempting alternative configurations.
|
|
170
|
+
|
|
171
|
+
TLS negotiation must succeed before authentication is attempted.
|
|
172
|
+
|
|
173
|
+
Each retrieval operation manages its own connection lifecycle internally. Configuration, retry strategies and recovery mechanisms remain the responsibility of the consuming application.
|
|
174
|
+
|
|
175
|
+
**MailAdapter abstracts protocol mechanics, not configuration decisions.**
|
|
176
|
+
|
|
177
|
+
## Exception Handling
|
|
178
|
+
|
|
179
|
+
MailAdapter provides a common exception hierarchy rooted in `MailAdapterError`.
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from mailadapter import (
|
|
183
|
+
MailAdapterError,
|
|
184
|
+
AuthenticationError,
|
|
185
|
+
EmailConnectionError,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
try:
|
|
189
|
+
emails = client.fetch_all_emails()
|
|
190
|
+
|
|
191
|
+
except AuthenticationError:
|
|
192
|
+
print("Authentication failed")
|
|
193
|
+
|
|
194
|
+
except EmailConnectionError:
|
|
195
|
+
print("Connection failed")
|
|
196
|
+
|
|
197
|
+
except MailAdapterError as exc:
|
|
198
|
+
print(f"Email operation failed: {exc}")
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Underlying protocol exceptions are preserved through exception chaining where applicable.
|
|
202
|
+
|
|
203
|
+
## Project Status
|
|
204
|
+
|
|
205
|
+
MailAdapter is currently under active development. The initial release focuses on IMAP retrieval. SMTP and additional authentication mechanisms are planned for subsequent releases.
|
|
206
|
+
|
|
207
|
+
## Roadmap
|
|
208
|
+
|
|
209
|
+
### v0.1.0 — IMAP Foundation
|
|
210
|
+
|
|
211
|
+
- Synchronous and asynchronous IMAP clients.
|
|
212
|
+
- Search criteria and email filtering.
|
|
213
|
+
- Date normalization.
|
|
214
|
+
- Provider presets.
|
|
215
|
+
- TLS configuration.
|
|
216
|
+
- Structured exception handling.
|
|
217
|
+
|
|
218
|
+
### v0.2.0 — Email Operations
|
|
219
|
+
|
|
220
|
+
- Synchronous and asynchronous SMTP clients.
|
|
221
|
+
- Attachment management.
|
|
222
|
+
- Extended mailbox operations.
|
|
223
|
+
|
|
224
|
+
### v0.3.0 — Extended Functionality
|
|
225
|
+
|
|
226
|
+
- OAuth2 authentication.
|
|
227
|
+
- Optional connection reuse.
|
|
228
|
+
- Advanced search expressions.
|
|
229
|
+
- Expanded provider support.
|
|
230
|
+
|
|
231
|
+
### v1.0.0 — Stable Release
|
|
232
|
+
|
|
233
|
+
- Stable public API.
|
|
234
|
+
- Comprehensive documentation.
|
|
235
|
+
- Expanded integration testing.
|
|
236
|
+
- Defined compatibility guarantees.
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
git clone https://github.com/KarstCoding/mailadapter.git
|
|
242
|
+
cd mailadapter
|
|
243
|
+
|
|
244
|
+
python -m venv .venv
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Activate the virtual environment and install the package in editable mode:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
python -m pip install -e .
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Contributing
|
|
254
|
+
|
|
255
|
+
Contributions, bug reports and feature requests are welcome.
|
|
256
|
+
|
|
257
|
+
MailAdapter prioritizes explicit interfaces, readability, maintainability and predictable behavior over unnecessary abstraction.
|
|
258
|
+
|
|
259
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and the [Architecture Decision Records](docs/adr/) for further information.
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
MailAdapter is distributed under the [MIT License](LICENSE).
|
|
264
|
+
|
|
265
|
+
Developed and maintained by [KarstCoding](https://karstcoding.com).
|
|
266
|
+
Docs: (https://karstcoding.com/open-source/mailadapter)
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# MailAdapter
|
|
2
|
+
|
|
3
|
+
A lightweight, typed Python library for integrating email functionality into synchronous and asynchronous applications.
|
|
4
|
+
|
|
5
|
+
MailAdapter abstracts email protocol operations and connection management while maintaining explicit configuration and predictable execution behavior.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Synchronous and asynchronous IMAP clients.
|
|
10
|
+
- Email retrieval and composable search criteria.
|
|
11
|
+
- Automatic date normalization.
|
|
12
|
+
- Predefined and custom server configurations.
|
|
13
|
+
- Implicit TLS and STARTTLS support.
|
|
14
|
+
- Automatic connection lifecycle management.
|
|
15
|
+
- Structured exception handling.
|
|
16
|
+
- Strict, fail-fast connection establishment.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install mailadapter
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For development releases:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install --pre mailadapter
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Requires Python 3.11 or later.
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Synchronous Client
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import os
|
|
38
|
+
|
|
39
|
+
from mailadapter import IMAPClient, IMAPServers
|
|
40
|
+
|
|
41
|
+
client = IMAPClient(
|
|
42
|
+
server=IMAPServers.GMAIL,
|
|
43
|
+
username=os.environ["EMAIL_USERNAME"],
|
|
44
|
+
password=os.environ["EMAIL_PASSWORD"],
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
emails = client.fetch_all_emails()
|
|
48
|
+
|
|
49
|
+
for email in emails:
|
|
50
|
+
print(email["Subject"])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Asynchronous Client
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import asyncio
|
|
57
|
+
import os
|
|
58
|
+
|
|
59
|
+
from mailadapter import AsyncIMAPClient, IMAPServers
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
async def main():
|
|
63
|
+
client = AsyncIMAPClient(
|
|
64
|
+
server=IMAPServers.GMAIL,
|
|
65
|
+
username=os.environ["EMAIL_USERNAME"],
|
|
66
|
+
password=os.environ["EMAIL_PASSWORD"],
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
emails = await client.fetch_all_emails()
|
|
70
|
+
|
|
71
|
+
for email in emails:
|
|
72
|
+
print(email["Subject"])
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
asyncio.run(main())
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Asynchronous operations are thread-backed using `asyncio.to_thread()`. Cancellation does not terminate an already-running blocking operation.
|
|
79
|
+
|
|
80
|
+
## Email Retrieval
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
client.fetch_all_emails()
|
|
84
|
+
client.fetch_unread()
|
|
85
|
+
client.fetch_emails_by_sender("sender@example.com")
|
|
86
|
+
client.fetch_emails_by_date("2026-12-01")
|
|
87
|
+
|
|
88
|
+
client.fetch_emails_by_date_range(
|
|
89
|
+
start="2026-12-01",
|
|
90
|
+
end="2027-01-01",
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Multiple search criteria can be combined:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from mailadapter import SearchCriteria
|
|
98
|
+
|
|
99
|
+
emails = client.fetch(
|
|
100
|
+
SearchCriteria(
|
|
101
|
+
sender="sender@example.com",
|
|
102
|
+
subject="Invoice",
|
|
103
|
+
since="2026-12-01",
|
|
104
|
+
unread=True,
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Fetched messages are returned as standard-library `EmailMessage` objects. Retrieval does not mark messages as read.
|
|
110
|
+
|
|
111
|
+
Date filters accept strings, `date` and `datetime` objects. Date ranges are start-inclusive and end-exclusive. ISO 8601 date strings are recommended.
|
|
112
|
+
|
|
113
|
+
## Server Configuration
|
|
114
|
+
|
|
115
|
+
MailAdapter includes presets for common email providers, including Gmail, Outlook, Microsoft 365, Yahoo, iCloud, GMX and others.
|
|
116
|
+
|
|
117
|
+
Custom servers can be configured explicitly:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from mailadapter import ServerConfig, TLSMode
|
|
121
|
+
|
|
122
|
+
server = ServerConfig(
|
|
123
|
+
host="mail.example.com",
|
|
124
|
+
port=993,
|
|
125
|
+
tls=TLSMode.IMPLICIT,
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Supported encryption modes:
|
|
130
|
+
|
|
131
|
+
| Mode | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `TLSMode.IMPLICIT` | TLS encryption from connection establishment. |
|
|
134
|
+
| `TLSMode.STARTTLS` | Explicit TLS upgrade before authentication. |
|
|
135
|
+
|
|
136
|
+
Some providers require application-specific passwords or OAuth2. The current implementation supports username-and-password authentication.
|
|
137
|
+
|
|
138
|
+
## Connection Policy
|
|
139
|
+
|
|
140
|
+
MailAdapter follows a strict, fail-fast connection policy.
|
|
141
|
+
|
|
142
|
+
Connections are established exclusively according to the supplied configuration. The library does not perform:
|
|
143
|
+
|
|
144
|
+
- Automatic server or port discovery.
|
|
145
|
+
- Fallback to alternative connection settings.
|
|
146
|
+
- Fallback between TLS modes.
|
|
147
|
+
- Fallback to unencrypted connections.
|
|
148
|
+
- Automatic authentication strategy switching.
|
|
149
|
+
- Automatic connection retries.
|
|
150
|
+
|
|
151
|
+
Failed operations raise exceptions rather than silently attempting alternative configurations.
|
|
152
|
+
|
|
153
|
+
TLS negotiation must succeed before authentication is attempted.
|
|
154
|
+
|
|
155
|
+
Each retrieval operation manages its own connection lifecycle internally. Configuration, retry strategies and recovery mechanisms remain the responsibility of the consuming application.
|
|
156
|
+
|
|
157
|
+
**MailAdapter abstracts protocol mechanics, not configuration decisions.**
|
|
158
|
+
|
|
159
|
+
## Exception Handling
|
|
160
|
+
|
|
161
|
+
MailAdapter provides a common exception hierarchy rooted in `MailAdapterError`.
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from mailadapter import (
|
|
165
|
+
MailAdapterError,
|
|
166
|
+
AuthenticationError,
|
|
167
|
+
EmailConnectionError,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
try:
|
|
171
|
+
emails = client.fetch_all_emails()
|
|
172
|
+
|
|
173
|
+
except AuthenticationError:
|
|
174
|
+
print("Authentication failed")
|
|
175
|
+
|
|
176
|
+
except EmailConnectionError:
|
|
177
|
+
print("Connection failed")
|
|
178
|
+
|
|
179
|
+
except MailAdapterError as exc:
|
|
180
|
+
print(f"Email operation failed: {exc}")
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Underlying protocol exceptions are preserved through exception chaining where applicable.
|
|
184
|
+
|
|
185
|
+
## Project Status
|
|
186
|
+
|
|
187
|
+
MailAdapter is currently under active development. The initial release focuses on IMAP retrieval. SMTP and additional authentication mechanisms are planned for subsequent releases.
|
|
188
|
+
|
|
189
|
+
## Roadmap
|
|
190
|
+
|
|
191
|
+
### v0.1.0 — IMAP Foundation
|
|
192
|
+
|
|
193
|
+
- Synchronous and asynchronous IMAP clients.
|
|
194
|
+
- Search criteria and email filtering.
|
|
195
|
+
- Date normalization.
|
|
196
|
+
- Provider presets.
|
|
197
|
+
- TLS configuration.
|
|
198
|
+
- Structured exception handling.
|
|
199
|
+
|
|
200
|
+
### v0.2.0 — Email Operations
|
|
201
|
+
|
|
202
|
+
- Synchronous and asynchronous SMTP clients.
|
|
203
|
+
- Attachment management.
|
|
204
|
+
- Extended mailbox operations.
|
|
205
|
+
|
|
206
|
+
### v0.3.0 — Extended Functionality
|
|
207
|
+
|
|
208
|
+
- OAuth2 authentication.
|
|
209
|
+
- Optional connection reuse.
|
|
210
|
+
- Advanced search expressions.
|
|
211
|
+
- Expanded provider support.
|
|
212
|
+
|
|
213
|
+
### v1.0.0 — Stable Release
|
|
214
|
+
|
|
215
|
+
- Stable public API.
|
|
216
|
+
- Comprehensive documentation.
|
|
217
|
+
- Expanded integration testing.
|
|
218
|
+
- Defined compatibility guarantees.
|
|
219
|
+
|
|
220
|
+
## Development
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
git clone https://github.com/KarstCoding/mailadapter.git
|
|
224
|
+
cd mailadapter
|
|
225
|
+
|
|
226
|
+
python -m venv .venv
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Activate the virtual environment and install the package in editable mode:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
python -m pip install -e .
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Contributing
|
|
236
|
+
|
|
237
|
+
Contributions, bug reports and feature requests are welcome.
|
|
238
|
+
|
|
239
|
+
MailAdapter prioritizes explicit interfaces, readability, maintainability and predictable behavior over unnecessary abstraction.
|
|
240
|
+
|
|
241
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and the [Architecture Decision Records](docs/adr/) for further information.
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MailAdapter is distributed under the [MIT License](LICENSE).
|
|
246
|
+
|
|
247
|
+
Developed and maintained by [KarstCoding](https://karstcoding.com).
|
|
248
|
+
Docs: (https://karstcoding.com/open-source/mailadapter)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting Vulnerabilities
|
|
4
|
+
|
|
5
|
+
If you discover a security vulnerability in MailAdapter, please report it privately through [GitHub Security Advisories](https://github.com/KarstCoding/mailadapter/security/advisories/new).
|
|
6
|
+
|
|
7
|
+
Please do not disclose security vulnerabilities, credentials or sensitive email content in public issues.
|
|
8
|
+
|
|
9
|
+
## Security Principles
|
|
10
|
+
|
|
11
|
+
MailAdapter follows a strict connection policy:
|
|
12
|
+
|
|
13
|
+
- TLS certificate verification is enabled.
|
|
14
|
+
- Authentication requires a successfully established encrypted connection.
|
|
15
|
+
- No fallback to unencrypted connections is permitted.
|
|
16
|
+
- No automatic connection retries or alternative connection strategies are performed.
|
|
17
|
+
|
|
18
|
+
Consumers are responsible for securely managing credentials and providing valid connection configurations.
|
|
19
|
+
|
|
20
|
+
## Supported Versions
|
|
21
|
+
|
|
22
|
+
MailAdapter is currently under active development. Security fixes are applied to the latest development version.
|
|
23
|
+
|
|
24
|
+
## Maintainer
|
|
25
|
+
|
|
26
|
+
[KarstCoding](https://karstcoding.com)
|