Metadata-Version: 2.4
Name: pyresend
Version: 1.0.0
Summary: A lightweight, zero-dependency Python SDK for the Resend Email API (https://resend.com)
Author-email: Nguyen Quoc Anh <developer@tenmiencuaban.com>
Keywords: resend,email,sdk,smtp,transactional-email,api,mail
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Communications :: Email
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# PyResend 📧

[![PyPI version](https://img.shields.io/pypi/v/pyresend.svg)](https://pypi.org/project/pyresend/)
[![Python Version](https://img.shields.io/pypi/pyversions/pyresend.svg)](https://pypi.org/project/pyresend/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A lightweight, zero-dependency Python SDK for the **[Resend Email API](https://resend.com/docs/introduction)**.

---

## ⚡ Features

- **🚀 Zero External Dependencies**: Built entirely on standard Python library (`urllib`, `json`, `base64`).
- **🛡️ Cloudflare Bot Protection Bypass**: Automatic custom `User-Agent` handling preventing Cloudflare 1010 blocks.
- **✉️ Full Email API Support**: Send HTML/Text emails, attachments, CC, BCC, tags, and scheduled emails.
- **📎 Automatic Attachment Base64 Encoding**: Automatically reads file paths or raw bytes and encodes them to base64.
- **🌐 Domains & API Keys API**: Manage domains and API keys via Python methods.
- **💻 Built-in CLI Tool**: Send emails directly from terminal.

---

## 📦 Installation

### Option 1: Via PyPI
```bash
pip install pyresend
```

### Option 2: Directly from GitHub
```bash
pip install git+https://github.com/nguyenquocanhz/pyresend.git
```

---

## 🚀 Quick Start Examples

### 1. Send HTML Email

```python
from pyresend import Resend

# Pass your API key or set RESEND_API_KEY environment variable
resend = Resend(api_key="re_JQ6uJLyg_5oUMtDYUn31v7sTPU2gHSNxi")

r = resend.send_email(
    from_email="Acme <onboarding@resend.dev>",
    to="delivered@resend.dev",
    subject="Hello World from PyResend!",
    html="<h1>It works!</h1><p>Sent using PyResend SDK.</p>"
)

print("Email sent successfully! ID:", r["id"])
```

---

### 2. Send Email with Attachments

```python
from pyresend import Resend

resend = Resend(api_key="re_JQ6uJLyg_5oUMtDYUn31v7sTPU2gHSNxi")

resend.send_email(
    from_email="Acme <onboarding@resend.dev>",
    to="delivered@resend.dev",
    subject="Monthly Invoice",
    html="<p>Please find your invoice attached.</p>",
    attachments=[
        {
            "filename": "invoice.pdf",
            "path": "./files/invoice.pdf" # Automatically encodes to Base64
        }
    ]
)
```

---

### 3. CLI Usage

```bash
pyresend send \
  --api-key "re_JQ6uJLyg_5oUMtDYUn31v7sTPU2gHSNxi" \
  --from "Acme <onboarding@resend.dev>" \
  --to "delivered@resend.dev" \
  --subject "Test from CLI" \
  --html "<h1>Hello from PyResend CLI!</h1>"
```

---

## 📄 License

Distributed under the MIT License. See [LICENSE](file:///d:/PyResend/LICENSE) for details.
