Metadata-Version: 2.4
Name: engagelab-email
Version: 0.1.0
Summary: Python SDK for EngageLab Email sending APIs.
License: MIT
Keywords: engagelab,email,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# engagelab-email

Python SDK for EngageLab Email sending APIs.

Supported sending APIs:

- Normal email: `POST /v1/mail/send`
- Template email: `POST /v1/mail/sendtemplate`
- Calendar email: `POST /v1/mail/sendcalendar`
- MIME email: `POST /v1/mail/send_mime`

Default base URLs:

- Singapore: `https://email.api.engagelab.cc`
- Turkey: `https://emailapi-tr.engagelab.com`

## Install

```bash
pip install engagelab-email
```

## Local Development

```bash
python -m pip install -e .
python -m unittest discover -s tests
```

## Normal Email

```python
from engagelab_email import EngageLabEmailClient

client = EngageLabEmailClient(
    api_user="your_api_user",
    api_key="your_api_key",
)

result = client.send({
    "from": "EngageLab Team <support@mail.engagelab.com>",
    "to": ["user@example.com"],
    "body": {
        "subject": "Welcome",
        "content": {
            "html": "<p>Hello from EngageLab</p>",
            "text": "Hello from EngageLab",
        },
    },
})

print(result)
```

## Template Email

```python
client.send_template({
    "from": "support@mail.engagelab.com",
    "to": ["user@example.com"],
    "body": {
        "template_invoke_name": "month_bill",
        "subject": "Monthly Bill",
        "vars": {
            "%name%": ["Jack"],
            "%money%": ["30"],
        },
    },
})
```

## Calendar Email

```python
client.send_calendar({
    "from": "EngageLab Team <support@mail.engagelab.com>",
    "to": ["user@example.com"],
    "body": {
        "subject": "Meeting",
        "content": {
            "html": "<p>Please join the meeting.</p>",
        },
        "calendar": {
            "time_zone_id": "Asia/Shanghai",
            "start_time": "2026-06-10 10:00:00",
            "end_time": "2026-06-10 11:00:00",
            "title": "Project Meeting",
            "organizer": {
                "name": "EngageLab",
                "email": "support@mail.engagelab.com",
            },
            "location": "Online",
        },
    },
})
```

## MIME Email

```python
client.send_mime({
    "from": "EngageLab Team <support@mail.engagelab.com>",
    "to": ["user@example.com"],
    "body": {
        "subject": "Raw MIME",
        "content": {
            "raw_message": "From: test@example.com\r\nTo: user@example.com\r\nSubject: Raw MIME\r\n\r\nHello",
        },
    },
})
```

## Turkey Data Center

```python
from engagelab_email import EngageLabEmailClient, TURKEY_BASE_URL

client = EngageLabEmailClient(
    api_user="your_api_user",
    api_key="your_api_key",
    base_url=TURKEY_BASE_URL,
)
```

## Error Handling

```python
from engagelab_email import EngageLabEmailError

try:
    client.send({"body": {}})
except EngageLabEmailError as error:
    print(error.status, error.code, error.response)
```

The SDK accepts request payloads in the same shape as EngageLab's REST API.
