Metadata-Version: 2.4
Name: pyresend
Version: 1.1.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 Marketing Email with Templates

`pyresend` comes with built-in, responsive HTML email marketing templates (`welcome`, `promotional`, `newsletter`):

```python
from pyresend import Resend, templates

resend = Resend(api_key="re_JQ6uJLyg_5oUMtDYUn31v7sTPU2gHSNxi")

# 1. Promotional Email with Discount Code
promo_html = templates.promotional(
    title="Siêu Ưu Đãi Mùa Hè 2026",
    discount_code="SUMMER2026",
    discount_text="Giảm ngay 30% cho đơn hàng đầu tiên",
    description="Nhận ưu đãi độc quyền từ hệ thống dịch vụ của chúng tôi.",
    button_text="Mua Ngay Với Mã Giảm Giá",
    button_url="https://resend.com",
    brand_name="MyBrand"
)

resend.send_email(
    from_email="Acme <onboarding@resend.dev>",
    to="delivered@resend.dev",
    subject="🎁 Siêu Ưu Đãi: Mã Giảm Giá SUMMER2026!",
    html=promo_html
)

# 2. Welcome Email for New Users
welcome_html = templates.welcome(
    name="Nguyễn Văn A",
    title="Chào mừng bạn đến với hệ thống!",
    button_text="Truy cập Trang cá nhân",
    button_url="https://resend.com",
    brand_name="MyBrand"
)
```

---

### 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.
