mails-agent 1.4.0b1__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.
@@ -0,0 +1,30 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # IDE
18
+ .idea/
19
+ .vscode/
20
+ *.swp
21
+ *.swo
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ .coverage
26
+ htmlcov/
27
+
28
+ # OS
29
+ .DS_Store
30
+ Thumbs.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Gene Dai
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,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: mails-agent
3
+ Version: 1.4.0b1
4
+ Summary: Python SDK for mails-agent — email capabilities for AI agents
5
+ Project-URL: Homepage, https://mails0.com
6
+ Project-URL: Repository, https://github.com/Digidai/mails-python
7
+ Project-URL: Documentation, https://github.com/Digidai/mails-python#readme
8
+ Author: Gene Dai
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai-agent,email,mails,verification-code
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Requires-Python: >=3.9
17
+ Requires-Dist: httpx>=0.24.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # mails-agent
21
+
22
+ Python SDK for [mails0.com](https://mails0.com) -- email capabilities for AI agents.
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ pip install mails-agent
28
+ ```
29
+
30
+ ## Quick start
31
+
32
+ ```python
33
+ from mails_agent import MailsClient
34
+
35
+ client = MailsClient(
36
+ api_url="https://mails-worker.your-domain.com",
37
+ token="your-api-token",
38
+ mailbox="agent@mails0.com",
39
+ )
40
+
41
+ # Send an email
42
+ result = client.send(
43
+ to="user@example.com",
44
+ subject="Hello from my agent",
45
+ text="This email was sent by an AI agent.",
46
+ )
47
+ print(f"Sent: {result.id}")
48
+
49
+ # Check inbox
50
+ emails = client.get_inbox(limit=5)
51
+ for email in emails:
52
+ print(f"{email.from_address}: {email.subject}")
53
+
54
+ # Wait for a verification code (long-polls up to 30s)
55
+ code = client.wait_for_code(timeout=30)
56
+ if code:
57
+ print(f"Got code: {code.code}")
58
+ ```
59
+
60
+ ## API reference
61
+
62
+ ### `MailsClient(api_url, token, mailbox, *, timeout=60.0)`
63
+
64
+ Create a synchronous client. Supports use as a context manager:
65
+
66
+ ```python
67
+ with MailsClient(api_url, token, mailbox) as client:
68
+ emails = client.get_inbox()
69
+ ```
70
+
71
+ ---
72
+
73
+ ### `send(to, subject, *, text=None, html=None, reply_to=None, attachments=None) -> SendResult`
74
+
75
+ Send an email. `to` can be a single address or a list.
76
+
77
+ ```python
78
+ result = client.send(
79
+ to=["alice@example.com", "bob@example.com"],
80
+ subject="Team update",
81
+ html="<h1>Update</h1><p>Everything is on track.</p>",
82
+ reply_to="noreply@mails0.com",
83
+ )
84
+ ```
85
+
86
+ **Attachments** are passed as a list of dicts:
87
+
88
+ ```python
89
+ client.send(
90
+ to="user@example.com",
91
+ subject="Report",
92
+ text="See attached.",
93
+ attachments=[{
94
+ "filename": "report.pdf",
95
+ "content": base64_encoded_string,
96
+ "content_type": "application/pdf",
97
+ }],
98
+ )
99
+ ```
100
+
101
+ ---
102
+
103
+ ### `get_inbox(*, limit=20, offset=0, direction=None, query=None) -> list[Email]`
104
+
105
+ Fetch emails from the inbox with optional filtering.
106
+
107
+ ```python
108
+ # Get latest 10 inbound emails
109
+ emails = client.get_inbox(limit=10, direction="inbound")
110
+
111
+ # Search for emails containing "invoice"
112
+ emails = client.get_inbox(query="invoice")
113
+ ```
114
+
115
+ ---
116
+
117
+ ### `search(query, *, limit=20, direction=None) -> list[Email]`
118
+
119
+ Search emails by query string. Convenience wrapper around `get_inbox`.
120
+
121
+ ```python
122
+ results = client.search("verification code", limit=5)
123
+ ```
124
+
125
+ ---
126
+
127
+ ### `get_email(email_id) -> Email`
128
+
129
+ Fetch a single email by its ID. Raises `NotFoundError` if it does not exist.
130
+
131
+ ```python
132
+ email = client.get_email("abc-123")
133
+ print(email.body_text)
134
+ ```
135
+
136
+ ---
137
+
138
+ ### `wait_for_code(*, timeout=30) -> VerificationCode | None`
139
+
140
+ Long-poll the server for a verification code. Returns `None` if no code arrives within the timeout.
141
+
142
+ ```python
143
+ code = client.wait_for_code(timeout=60)
144
+ if code:
145
+ print(f"Code: {code.code}, From: {code.from_address}")
146
+ ```
147
+
148
+ ---
149
+
150
+ ### `delete_email(email_id) -> bool`
151
+
152
+ Delete an email. Returns `True` if deleted, `False` if not found.
153
+
154
+ ```python
155
+ deleted = client.delete_email("abc-123")
156
+ ```
157
+
158
+ ## Async usage
159
+
160
+ All methods are available as `async` via `AsyncMailsClient`:
161
+
162
+ ```python
163
+ import asyncio
164
+ from mails_agent import AsyncMailsClient
165
+
166
+ async def main():
167
+ async with AsyncMailsClient(
168
+ api_url="https://mails-worker.your-domain.com",
169
+ token="your-api-token",
170
+ mailbox="agent@mails0.com",
171
+ ) as client:
172
+ # Send
173
+ result = await client.send("user@example.com", "Hello", text="Hi!")
174
+
175
+ # Inbox
176
+ emails = await client.get_inbox()
177
+
178
+ # Wait for code
179
+ code = await client.wait_for_code(timeout=30)
180
+
181
+ asyncio.run(main())
182
+ ```
183
+
184
+ ## Data models
185
+
186
+ ### `Email`
187
+
188
+ | Field | Type | Description |
189
+ |-------|------|-------------|
190
+ | `id` | `str` | Unique email ID |
191
+ | `mailbox` | `str` | Mailbox address |
192
+ | `from_address` | `str` | Sender email |
193
+ | `from_name` | `str` | Sender display name |
194
+ | `subject` | `str` | Subject line |
195
+ | `direction` | `str` | `"inbound"` or `"outbound"` |
196
+ | `status` | `str` | `"received"`, `"sent"`, `"failed"`, `"queued"` |
197
+ | `received_at` | `str` | ISO 8601 timestamp |
198
+ | `has_attachments` | `bool` | Whether email has attachments |
199
+ | `attachment_count` | `int` | Number of attachments |
200
+ | `body_text` | `str` | Plain text body |
201
+ | `body_html` | `str` | HTML body |
202
+ | `code` | `str \| None` | Extracted verification code, if any |
203
+
204
+ ### `SendResult`
205
+
206
+ | Field | Type | Description |
207
+ |-------|------|-------------|
208
+ | `id` | `str` | Message ID |
209
+ | `provider` | `str` | Send provider used |
210
+ | `provider_id` | `str \| None` | Provider-specific ID |
211
+
212
+ ### `VerificationCode`
213
+
214
+ | Field | Type | Description |
215
+ |-------|------|-------------|
216
+ | `code` | `str` | The verification code |
217
+ | `from_address` | `str` | Sender of the code email |
218
+ | `subject` | `str` | Subject of the code email |
219
+
220
+ ## Exceptions
221
+
222
+ | Exception | When |
223
+ |-----------|------|
224
+ | `MailsError` | Base class for all SDK errors |
225
+ | `AuthError` | 401 or 403 response |
226
+ | `NotFoundError` | 404 response |
227
+ | `ApiError` | Any other non-2xx response (has `.status_code`) |
228
+
229
+ ## License
230
+
231
+ MIT
@@ -0,0 +1,212 @@
1
+ # mails-agent
2
+
3
+ Python SDK for [mails0.com](https://mails0.com) -- email capabilities for AI agents.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install mails-agent
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```python
14
+ from mails_agent import MailsClient
15
+
16
+ client = MailsClient(
17
+ api_url="https://mails-worker.your-domain.com",
18
+ token="your-api-token",
19
+ mailbox="agent@mails0.com",
20
+ )
21
+
22
+ # Send an email
23
+ result = client.send(
24
+ to="user@example.com",
25
+ subject="Hello from my agent",
26
+ text="This email was sent by an AI agent.",
27
+ )
28
+ print(f"Sent: {result.id}")
29
+
30
+ # Check inbox
31
+ emails = client.get_inbox(limit=5)
32
+ for email in emails:
33
+ print(f"{email.from_address}: {email.subject}")
34
+
35
+ # Wait for a verification code (long-polls up to 30s)
36
+ code = client.wait_for_code(timeout=30)
37
+ if code:
38
+ print(f"Got code: {code.code}")
39
+ ```
40
+
41
+ ## API reference
42
+
43
+ ### `MailsClient(api_url, token, mailbox, *, timeout=60.0)`
44
+
45
+ Create a synchronous client. Supports use as a context manager:
46
+
47
+ ```python
48
+ with MailsClient(api_url, token, mailbox) as client:
49
+ emails = client.get_inbox()
50
+ ```
51
+
52
+ ---
53
+
54
+ ### `send(to, subject, *, text=None, html=None, reply_to=None, attachments=None) -> SendResult`
55
+
56
+ Send an email. `to` can be a single address or a list.
57
+
58
+ ```python
59
+ result = client.send(
60
+ to=["alice@example.com", "bob@example.com"],
61
+ subject="Team update",
62
+ html="<h1>Update</h1><p>Everything is on track.</p>",
63
+ reply_to="noreply@mails0.com",
64
+ )
65
+ ```
66
+
67
+ **Attachments** are passed as a list of dicts:
68
+
69
+ ```python
70
+ client.send(
71
+ to="user@example.com",
72
+ subject="Report",
73
+ text="See attached.",
74
+ attachments=[{
75
+ "filename": "report.pdf",
76
+ "content": base64_encoded_string,
77
+ "content_type": "application/pdf",
78
+ }],
79
+ )
80
+ ```
81
+
82
+ ---
83
+
84
+ ### `get_inbox(*, limit=20, offset=0, direction=None, query=None) -> list[Email]`
85
+
86
+ Fetch emails from the inbox with optional filtering.
87
+
88
+ ```python
89
+ # Get latest 10 inbound emails
90
+ emails = client.get_inbox(limit=10, direction="inbound")
91
+
92
+ # Search for emails containing "invoice"
93
+ emails = client.get_inbox(query="invoice")
94
+ ```
95
+
96
+ ---
97
+
98
+ ### `search(query, *, limit=20, direction=None) -> list[Email]`
99
+
100
+ Search emails by query string. Convenience wrapper around `get_inbox`.
101
+
102
+ ```python
103
+ results = client.search("verification code", limit=5)
104
+ ```
105
+
106
+ ---
107
+
108
+ ### `get_email(email_id) -> Email`
109
+
110
+ Fetch a single email by its ID. Raises `NotFoundError` if it does not exist.
111
+
112
+ ```python
113
+ email = client.get_email("abc-123")
114
+ print(email.body_text)
115
+ ```
116
+
117
+ ---
118
+
119
+ ### `wait_for_code(*, timeout=30) -> VerificationCode | None`
120
+
121
+ Long-poll the server for a verification code. Returns `None` if no code arrives within the timeout.
122
+
123
+ ```python
124
+ code = client.wait_for_code(timeout=60)
125
+ if code:
126
+ print(f"Code: {code.code}, From: {code.from_address}")
127
+ ```
128
+
129
+ ---
130
+
131
+ ### `delete_email(email_id) -> bool`
132
+
133
+ Delete an email. Returns `True` if deleted, `False` if not found.
134
+
135
+ ```python
136
+ deleted = client.delete_email("abc-123")
137
+ ```
138
+
139
+ ## Async usage
140
+
141
+ All methods are available as `async` via `AsyncMailsClient`:
142
+
143
+ ```python
144
+ import asyncio
145
+ from mails_agent import AsyncMailsClient
146
+
147
+ async def main():
148
+ async with AsyncMailsClient(
149
+ api_url="https://mails-worker.your-domain.com",
150
+ token="your-api-token",
151
+ mailbox="agent@mails0.com",
152
+ ) as client:
153
+ # Send
154
+ result = await client.send("user@example.com", "Hello", text="Hi!")
155
+
156
+ # Inbox
157
+ emails = await client.get_inbox()
158
+
159
+ # Wait for code
160
+ code = await client.wait_for_code(timeout=30)
161
+
162
+ asyncio.run(main())
163
+ ```
164
+
165
+ ## Data models
166
+
167
+ ### `Email`
168
+
169
+ | Field | Type | Description |
170
+ |-------|------|-------------|
171
+ | `id` | `str` | Unique email ID |
172
+ | `mailbox` | `str` | Mailbox address |
173
+ | `from_address` | `str` | Sender email |
174
+ | `from_name` | `str` | Sender display name |
175
+ | `subject` | `str` | Subject line |
176
+ | `direction` | `str` | `"inbound"` or `"outbound"` |
177
+ | `status` | `str` | `"received"`, `"sent"`, `"failed"`, `"queued"` |
178
+ | `received_at` | `str` | ISO 8601 timestamp |
179
+ | `has_attachments` | `bool` | Whether email has attachments |
180
+ | `attachment_count` | `int` | Number of attachments |
181
+ | `body_text` | `str` | Plain text body |
182
+ | `body_html` | `str` | HTML body |
183
+ | `code` | `str \| None` | Extracted verification code, if any |
184
+
185
+ ### `SendResult`
186
+
187
+ | Field | Type | Description |
188
+ |-------|------|-------------|
189
+ | `id` | `str` | Message ID |
190
+ | `provider` | `str` | Send provider used |
191
+ | `provider_id` | `str \| None` | Provider-specific ID |
192
+
193
+ ### `VerificationCode`
194
+
195
+ | Field | Type | Description |
196
+ |-------|------|-------------|
197
+ | `code` | `str` | The verification code |
198
+ | `from_address` | `str` | Sender of the code email |
199
+ | `subject` | `str` | Subject of the code email |
200
+
201
+ ## Exceptions
202
+
203
+ | Exception | When |
204
+ |-----------|------|
205
+ | `MailsError` | Base class for all SDK errors |
206
+ | `AuthError` | 401 or 403 response |
207
+ | `NotFoundError` | 404 response |
208
+ | `ApiError` | Any other non-2xx response (has `.status_code`) |
209
+
210
+ ## License
211
+
212
+ MIT
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mails-agent"
7
+ version = "1.4.0b1"
8
+ description = "Python SDK for mails-agent — email capabilities for AI agents"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [{ name = "Gene Dai" }]
13
+ keywords = ["email", "ai-agent", "mails", "verification-code"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ ]
20
+ dependencies = ["httpx>=0.24.0"]
21
+
22
+ [project.urls]
23
+ Homepage = "https://mails0.com"
24
+ Repository = "https://github.com/Digidai/mails-python"
25
+ Documentation = "https://github.com/Digidai/mails-python#readme"
26
+
27
+ [tool.hatch.build.targets.wheel]
28
+ packages = ["src/mails_agent"]
@@ -0,0 +1,18 @@
1
+ """mails-agent — Python SDK for email capabilities for AI agents."""
2
+
3
+ from .client import AsyncMailsClient, MailsClient
4
+ from .exceptions import ApiError, AuthError, MailsError, NotFoundError
5
+ from .models import Email, SendResult, VerificationCode
6
+
7
+ __version__ = "1.4.0b1"
8
+ __all__ = [
9
+ "MailsClient",
10
+ "AsyncMailsClient",
11
+ "Email",
12
+ "SendResult",
13
+ "VerificationCode",
14
+ "MailsError",
15
+ "AuthError",
16
+ "NotFoundError",
17
+ "ApiError",
18
+ ]