Chapar (چاپار) is a Python-based tool for sending personalized HTML emails effortlessly. Inspired by the Persian word "Chapar," which refers to the ancient postal couriers who swiftly delivered messages across distances, this project modernizes the art of communication, enabling efficient and customizable email delivery for your needs.
Run the script with the folder containing your email_template.html
, recipients.csv
, and optionally a config.ini
:
python chapar.py newsletter0-ltr
- Supports only secure connections (SSL and TLS)
- minimal template and responsive modern templates (Just replace your texts)
- templates in RTL and LTR format
- interval between sends
This guide explains how to use Chapar with Docker for sending personalized HTML emails.
Build the Docker image from the project root directory:
docker build -t chapar .
Collecting workspace information
I'll help create a Dockerfile and docker-usage.md file for the Chapar email sending application. Here's what we'll create:
First, let's create a Dockerfile
:
# Use Python 3.9 slim image
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Copy requirements (if you have any external dependencies)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application code and templates
COPY src/ .
# Set environment variables for encoding
ENV PYTHONIOENCODING=utf8
ENV LANG=C.UTF-8
# Command to run the application
ENTRYPOINT ["python", "chapar.py"]
Now, let's create a requirements.txt
file (place it in the root directory):
configparser>=5.0.0
Here's the content for docker-usage.md
:
# Docker Usage Guide for Chapar
This guide explains how to use Chapar with Docker for sending personalized HTML emails.
## Building the Docker Image
Build the Docker image from the project root directory:
```bash
docker build -t chapar .
Run Chapar by mounting your newsletter folder and specifying the folder name:
docker run -v $(pwd)/src/newsletter0-ltr:/app/newsletter0-ltr chapar newsletter0-ltr
Your mounted directory should contain:
- email_template.html: Your HTML email template
- recipients.csv: CSV file with email recipients
- config.ini: SMTP and other configuration settings
- For LTR (Left-to-Right) template:
docker run -v $(pwd)/src/newsletter0-ltr:/app/newsletter0-ltr chapar newsletter0-ltr
- For RTL (Right-to-Left) template:
docker run -v $(pwd)/src/newsletter0-rtl:/app/newsletter0-rtl chapar newsletter0-rtl
Make sure your config.ini
file in the mounted directory contains proper SMTP settings:
[SMTP]
Host = smtp.example.com
Port = 587
Email = [email protected]
Password = your_password
Subject = Your Subject Here
DisplayName = Your Name
[Settings]
Interval = 5
- Always use secure SMTP connections (Port 587 for TLS or 465 for SSL)
- Keep your SMTP credentials secure and never commit them to version control
- Consider using environment variables for sensitive information
-
If you encounter encoding issues:
- Ensure all files are saved with UTF-8 encoding
- The Docker container is configured with UTF-8 support by default
-
For permission issues:
- Check the file permissions in your mounted directory
- Ensure the container has read access to all required files
-
For network issues:
- Verify your SMTP server settings
- Check if your host allows outgoing SMTP connections
This Docker setup allows you to:
- Package the Chapar application in a container
- Run it with different newsletter templates
- Mount local directories containing your email templates and configurations
- Handle both RTL and LTR templates properly with UTF-8 support
-
Install REST Client extension in VS Code:
-
Create test sample files in
/test/samples/
:
- Copy your template, recipients, and config files
- Modify with test data
-
Open
test/api.http
in VS Code -
Click "Send Request" above each test case to execute:
- Health check endpoint
- Email sending with valid files
- Error handling scenarios
- Health Check:
GET http://localhost:5000/api/health
- Send Emails:
POST http://localhost:5000/api/send
Content-Type: multipart/form-data
- View responses in the split pane that opens in VS Code
- docker support
- expose REST API
- more