Metadata-Version: 2.4
Name: serversmtp
Version: 0.4.0
Summary: Official Python SDK for the ServerSMTP transactional email API
License-Expression: MIT
Project-URL: Homepage, https://serversmtp.ro/docs#biblioteci
Keywords: email,smtp,transactional,serversmtp,amazon-ses,django
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# serversmtp (Python)

Official Python SDK for the [ServerSMTP](https://serversmtp.ro) transactional email API. Python 3.9+, standard library only.

```sh
pip install serversmtp
```

```python
import os
from serversmtp import ServerSMTP, ServerSMTPError

serversmtp = ServerSMTP(os.environ["SERVERSMTP_API_KEY"])

response = serversmtp.emails.send(
    {
        "from": "Shop <orders@your-domain.ro>",
        "to": "customer@example.com",
        "subject": "Order #1001 confirmed",
        "html": "<p>Thank you!</p>",
    },
    idempotency_key="order-1001-confirmation",
)
print(response.data["status"], response.idempotency_key)
```

Attachments, CC and BCC (up to 10 files, 10 MB in total; each address counts toward the quota):

```python
from serversmtp import attachment_from_path

serversmtp.emails.send({
    "from": "Shop <orders@your-domain.ro>",
    "to": "customer@example.com",
    "cc": "accounting@your-domain.ro",
    "bcc": ["archive@your-domain.ro"],
    "subject": "Invoice #1001",
    "text": "Your invoice is attached.",
    "attachments": [attachment_from_path("invoice-1001.pdf")],
})
```

- `emails.send()`, `emails.send_batch()`, `emails.schedule()` (timezone-aware `datetime` for `sendAt`)
- `scheduled.list()`, `scheduled.get()`, `scheduled.cancel()`, `verify_api_key()`
- `emails.get(request_id)`, `emails.list(limit=, offset=)`: sent emails with each recipient's status, tags and suppressed addresses
- Messages accept `headers` (up to 20 custom headers) and `tags` (up to 10 `{"name", "value"}`)
- `events.trigger(event, email, data=None, phone=None, audience_id=None)` starts the automations for an event (email and SMS steps):

```python
serversmtp.events.trigger("comanda.expediata", "client@example.com",
                          {"order_reference": "1001", "tracking_number": "AWB123"}, phone="0722 123 456")
```
- Errors raise `ServerSMTPError` with `status_code`, `fields`, `request_id` and `type`.

Docs: https://serversmtp.ro/docs#biblioteci
