# Python: set the module key, send, catch the exception

```python
import os
import resend
from resend.exceptions import ResendError

resend.api_key = os.environ["RESEND_API_KEY"]

params: resend.Emails.SendParams = {
    "from": "[SENDER]",
    "to": ["[RECIPIENT]"],
    "subject": "hello world",
    "html": "&lt;strong&gt;it works!&lt;/strong&gt;",
}

try:
    email = resend.Emails.send(params)
    print(email)
except ResendError as error:
    print(error)
```

## Checklist

- `resend.api_key` is module-level state. Set it once at startup from
  `os.environ`, not inside every call site.
- There is no `error` return value. If you port the Node pattern and check a
  second return value, failures pass silently. Wrap the call in
  try/except ResendError instead.
- `resend.Emails.send` is called on the class, not on a client instance. There
  is no `Resend(...)` constructor in the Python SDK.
- `SendParams` is a plain dict with string keys: from, to, subject, html.