SWECC Email Sender
An email automation library using SendGrid API. Supports both single and batch email sending with Markdown formatting and template substitution.
Features
- Single and batch email sending
- Markdown to HTML conversion with styling
- Template substitution support
- CSV and JSON data source support
- Preview and validation modes
Installation
pip install swecc-email-sender
Quick Start
Single Email
from swecc_email_sender import EmailSender
sender = EmailSender() # uses SENDGRID_API_KEY environment variable
success = sender.send_email(
to_email="recipient@example.com",
subject="Hello!",
content="This is a test email",
from_email="sender@example.com"
)
Markdown Email
success = sender.send_email(
to_email="recipient@example.com",
subject="Hello!",
content="# Hello World\n\nThis is a **markdown** email",
from_email="sender@example.com",
is_markdown=True
)
Template Email
template = """
Hello {name}!
Your order #{order_id} has been shipped to:
{address}
Thank you for your business!
"""
success = sender.send_email(
to_email="customer@example.com",
subject="Order #{order_id} Shipped",
content=template,
from_email="shop@example.com",
template_data={
"name": "John Doe",
"order_id": "12345",
"address": "123 Main St, City, Country"
}
)
Command Line Interface
The package includes a command-line interface for easy use:
# Single email
swecc-email-sender --from sender@example.com --to recipient@example.com --subject "Hello" --content "Test email"
# Markdown email
swecc-email-sender --from sender@example.com --to recipient@example.com --subject "Hello" --content "# Hello" --markdown
# Template with CSV data
swecc-email-sender --from sender@example.com --src recipients.csv --subject "Hello {name}" --template email.md
# Preview first email
swecc-email-sender --from sender@example.com --src data.json --subject "Hello" --template email.md --preview
# Validate templates
swecc-email-sender --from sender@example.com --src data.json --subject "Hello {name}" --template email.md --validate
Data File Formats
CSV Example (recipients.csv)
to_email,name,order_id,address
customer1@example.com,John Doe,12345,123 Main St
customer2@example.com,Jane Smith,12346,456 Oak Ave
JSON Example (data.json)
[
{
"to_email": "customer1@example.com",
"name": "John Doe",
"order_id": "12345",
"address": "123 Main St"
},
{
"to_email": "customer2@example.com",
"name": "Jane Smith",
"order_id": "12346",
"address": "456 Oak Ave"
}
]
Development
Setup
- Clone the repository:
git clone https://github.com/swecc/swecc-email-sender.git
cd swecc-email-sender
- Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
Running Tests
pytest
Code Style
The project uses:
- Black for code formatting
- isort for import sorting
- mypy for type checking
- flake8 for linting
To run all checks:
ruff --fix
isort .
mypy swecc_email_sender
flake8 swecc_email_sender
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for swecc-email-sender 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swecc_email_sender-1.0.7.tar.gz | 12.0 kB | Without provenance | Details for swecc_email_sender-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swecc_email_sender-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for swecc_email_sender-1.0.7-py3-none-any.whl |
Total release size: 22.2 kB
Release files / swecc_email_sender-1.0.7.tar.gz
| Download URL | swecc_email_sender-1.0.7.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
add83ccd9585b57961ad9d407ab7fa86cbbd0d2a1c0f2948db1a8654e42d7299
|
|
BLAKE2b-256 checksum How to use checksums |
2e7e3122260d7ad026bcb893fd508f22dd94fb9265ecb7350912c45a3350ec9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / swecc_email_sender-1.0.7-py3-none-any.whl
| Download URL | swecc_email_sender-1.0.7-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edfb45de3353ac66e3c3702b21062aa8866e3a2e66e308d1989f5f84c7c774cd
|
|
BLAKE2b-256 checksum How to use checksums |
41d1a35fb9a243949ac8d873bb98965c19f9fb50123716109fdc1430945a3460
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Security for swecc-email-sender 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.