# Python ile gönder

> Python'dan e-posta gönderme, talepler kütüphanesi ile.

## Önkoşullar

- `SENDTERN_API_KEY` olarak depolanan bir Sendtern [API anahtarı](https://sendtern.com/docs/authentication)
- Python 3.8 or newer

1. **Kurulum talepleri**: Herhangi bir HTTP istemcisi çalışabilir. Bu rehber `requests` kullanır.

```
pip install requests
```

2. **E-posta gönder**: 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. **Cevapları kontrol et.**: Başarılı bir talep e-posta kimliğiyle `200 OK`'yi geri verir. Daha sonra e-postayı aramaya kullanın.

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

> **tip:** Örnek göndericiyi [verilen alan adı](https://sendtern.com/docs/domains) adresinizle değiştirin.
