# पायथन के साथ भेजें

> Send email from Python with the requests library.

## पूर्व आवश्यकताएँ

- एक Sendtern [API कुंजी](https://sendtern.com/docs/authentication) `SENDTERN_API_KEY` के रूप में भंडारित
- Python 3.8 or newer

1. **संस्थापित निवेदन**: कोई भी एचटीटीपी क्लाएंट काम करता है. यह गाइड `requests` का उपयोग करता है.

```
pip install requests
```

2. **ईमेल भेजें**: Create `send.py`.

```
# send.py
import os
import uuid
import requests

res = requests.post(
    "https://sendtern.com/emails",
    headers={
        "Authorization": f"Bearer {os.environ['SENDTERN_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "from": "Acme <hello@mail.example.com>",
        "to": ["you@example.com"],
        "subject": "Hello from Python",
        "html": "<p>It works!</p>",
    },
    timeout=10,
)

res.raise_for_status()
print(res.json())
```

3. **जवाब जाँचें**: एक सफल निवेदन ईमेल आईडी के साथ `200 OK` लौटाता है. ईमेल को बाद में देखने के लिए इसका उपयोग करें.

```
{
  "id": "47be30ca-24b7-48fb-b35d-ff287b89e66d"
}
```

> **tip:** उदाहरण प्रेषक को अपने [सत्यापित डोमेन](https://sendtern.com/docs/domains) पर एक पता के साथ बदलें.
