> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Email

> Set up the Email resource in Python.

## Dependencies

```bash theme={null}
uv add aioimaplib aiosmtplib
```

For credential setup, see the [Email Setup](/home/setup/email) guide.

## Configuration

```python theme={null}
import os
from mirage import Workspace, MountMode
from mirage.resource.email import EmailConfig, EmailResource

config = EmailConfig(
    imap_host=os.environ["IMAP_HOST"],
    smtp_host=os.environ["SMTP_HOST"],
    username=os.environ["EMAIL_USERNAME"],
    password=os.environ["EMAIL_PASSWORD"],
)
resource = EmailResource(config=config)
ws = Workspace({"/email/": resource}, mode=MountMode.READ)
```

### Verify Connection

```python theme={null}
import asyncio

async def main():
    r = await ws.execute("ls /email/")
    print(await r.stdout_str())

asyncio.run(main())
```

This should print your IMAP folder names (e.g., `INBOX`, `Sent`,
`Drafts`, `Archive`).

## Config Reference

| Field       | Required | Default | Description              |
| ----------- | -------- | ------- | ------------------------ |
| `imap_host` | Yes      |         | IMAP server hostname     |
| `imap_port` | No       | `993`   | IMAP port                |
| `smtp_host` | Yes      |         | SMTP server hostname     |
| `smtp_port` | No       | `587`   | SMTP port                |
| `username`  | Yes      |         | Email address / login    |
| `password`  | Yes      |         | Password or app password |
| `use_ssl`   | No       | `True`  | Use SSL for IMAP         |
