Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Check out repository
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
uv run pytest tests/ -v --cov=tempmail --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14'
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
Expand Down
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ for message in messages:
- **Delete messages** - Clean up individual messages
- **Delete emails** - Remove email addresses and all their messages
- **Rate limit monitoring** - Track your API usage
- **Async support** - `AsyncTempMailClient` with the same interface for `async`/`await` code
- **Error handling** - Comprehensive exception handling
- **Type hints** - Full typing support for better development experience

Expand Down Expand Up @@ -137,6 +138,50 @@ if last_rate_limit:
print(f"Last known remaining: {last_rate_limit.remaining}")
```

## Async Usage

For `async`/`await` applications, use `AsyncTempMailClient`. It exposes the same
methods as `TempMailClient`, but each one is a coroutine you `await`.

```python
import asyncio

from tempmail import AsyncTempMailClient


async def main():
# Use as an async context manager so the underlying connection is closed
async with AsyncTempMailClient("your-api-key") as client:
# Create a temporary email address
email = await client.create_email()
print(f"Your temporary email: {email.email}")

# Check for messages
messages = await client.list_email_messages(email.email)
for message in messages:
print(f"From: {message.from_addr}")
print(f"Subject: {message.subject}")


asyncio.run(main())
```

If you don't use the context manager, close the client explicitly when you're done
to release the connection pool:

```python
client = AsyncTempMailClient("your-api-key")
try:
email = await client.create_email()
finally:
await client.close()
```

Every method available on `TempMailClient` (`create_email`, `list_domains`,
`list_email_messages`, `get_message`, `get_message_source_code`,
`download_attachment`, `delete_message`, `delete_email`, `get_rate_limit`) has an
awaitable equivalent on `AsyncTempMailClient`, and the same exceptions are raised.

## Error Handling

The library provides specific exception types for different error conditions:
Expand Down Expand Up @@ -174,8 +219,8 @@ cd temp-mail-python
# Install uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv sync --dev
# Install dependencies (including dev tools)
uv sync --extra dev
```

### Running Tests
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 5 - Production/Stable",
Expand Down
2 changes: 1 addition & 1 deletion tempmail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Official Temp Mail API (https://temp-mail.io) Wrapper for Python.
"""

__version__ = "1.0.1"
__version__ = "1.1.0"

from .client import TempMailClient
from .async_client import AsyncTempMailClient
Expand Down
62 changes: 62 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading