Skip to content

A simple Python based email sender (bulk, HTML format). "Chapar" refers to the ancient postal couriers who swiftly delivered messages across distances.

Notifications You must be signed in to change notification settings

aminmesbahi/chapar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Chapar (چاپار)

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.

Usage

Run the script with the folder containing your email_template.html, recipients.csv, and optionally a config.ini:

python chapar.py newsletter0-ltr

⚠️ This document, samples, and features will be improved! soon!

Current features

  • 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

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:

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 .

Running Chapar with Docker

Basic Usage

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

Directory Structure

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

Example Commands

  1. For LTR (Left-to-Right) template:
docker run -v $(pwd)/src/newsletter0-ltr:/app/newsletter0-ltr chapar newsletter0-ltr
  1. For RTL (Right-to-Left) template:
docker run -v $(pwd)/src/newsletter0-rtl:/app/newsletter0-rtl chapar newsletter0-rtl

Configuration

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

Security Notes

  • 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

Troubleshooting

  1. 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
  2. For permission issues:

    • Check the file permissions in your mounted directory
    • Ensure the container has read access to all required files
  3. For network issues:

    • Verify your SMTP server settings
    • Check if your host allows outgoing SMTP connections

This Docker setup allows you to:

  1. Package the Chapar application in a container
  2. Run it with different newsletter templates
  3. Mount local directories containing your email templates and configurations
  4. Handle both RTL and LTR templates properly with UTF-8 support

Running Tests

  1. Install REST Client extension in VS Code:

  2. Create test sample files in /test/samples/:

  • Copy your template, recipients, and config files
  • Modify with test data
  1. Open test/api.http in VS Code

  2. Click "Send Request" above each test case to execute:

  • Health check endpoint
  • Email sending with valid files
  • Error handling scenarios

Sample Test Cases

  1. Health Check:
GET http://localhost:5000/api/health
  1. Send Emails:
POST http://localhost:5000/api/send
Content-Type: multipart/form-data
  1. View responses in the split pane that opens in VS Code

Roadmap

  • docker support
  • expose REST API
  • more

About

A simple Python based email sender (bulk, HTML format). "Chapar" refers to the ancient postal couriers who swiftly delivered messages across distances.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published