A lightweight, zero-dependency Python SDK for the Resend Email API (https://resend.com)
Project description
PyResend 📧
A lightweight, zero-dependency Python SDK for the Resend Email API.
⚡ Features
- 🚀 Zero External Dependencies: Built entirely on standard Python library (
urllib,json,base64). - 🛡️ Cloudflare Bot Protection Bypass: Automatic custom
User-Agenthandling 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
pip install pyresend
Option 2: Directly from GitHub
pip install git+https://github.com/nguyenquocanhz/pyresend.git
🚀 Quick Start Examples
1. Send HTML Email
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):
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
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 for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyresend-1.1.0.tar.gz.
File metadata
- Download URL: pyresend-1.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbc2bfe1bdeda6b4923da10a2b334409c586c16b68acc707fedcc9ffb5883317
|
|
| MD5 |
b21d8743fc904c50d60d3cf31f8d0c4c
|
|
| BLAKE2b-256 |
b1cf21d85c04003d6011ebe22dd4ea48eeea958dcb6b494b0944d2837a80ce2f
|
File details
Details for the file pyresend-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pyresend-1.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
624786889208428890853425c7fe9b6c648e72d4f63b02b6ca995cd95475f2ee
|
|
| MD5 |
b6710764352d41c583568ae0e3564f19
|
|
| BLAKE2b-256 |
4866656b7b7b9e793cec3d08939dd77e4bca2b2e23068e2fa8829aa0f35e9035
|