Skip to main content

Email generator from CSV metadata and text template

Project description

pymailgen

Starting from the content of a CSV file and a template text file, pymailgen generates a list of emails to be sent out using a command-line SMTP client.

pymailgen does not send the emails itself, but it relies on external command-line tools to do it. pymailgen generates a shell script called sendall.sh that contains the list of commands to send out the emails using a command line STMP client.

This two-stage procedure has at least two advantages:

  1. you can inspect the emails before sending them out;
  2. in case of any issue in the sending, you have a log of what happened, and you can send the failed emails by just manually editing the sendall.sh script to keep the necessary corresponding commands.

At the moment, the only supported SMTP client is ssmtp. Some useful info to configure ssmtp for being used with Gmail are reported in this blog.

The logic of pymailgen is super simple. Therefore, it is easy to hack and customize in case a more complex logic is required to fill the template.

How it works

The elements required to generate the emails are:

  • the body of the email: a plain text file template with placeholders;
  • the header of the email: a plain text file with standard email header format;
  • the list of recipients: a CSV file with as many optional fields as needed.

The body and the header of the email can contain placeholders in the form of {Field}. For each email, pymailgen replaces the placeholder with the value in the column Field in a CSV file containing the necessary information. Association between field and placeholder is case-sensitive.

Each individual generated email is stored in a file named email_X.txt, where X is an incremental number.

Once all the necessary data are in place, run the following command to generate the emails:

pymailgen body.txt contacts.csv --ssmtp header.txt

If the SMTP client is properly configured, the emails will be sent out by running

bash sendall.sh

Blacklisting

If the input CSV file contains a column named Blacklist (case-sensitive), every row with any non-empty content in that column will be skipped during the generation of the set of emails.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymailgen-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymailgen-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pymailgen-0.1.0.tar.gz.

File metadata

  • Download URL: pymailgen-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for pymailgen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0ed1b5070e4da8fc99d42dbeb425e67c6ca1452191658fd06c348a9e75ad8db
MD5 6809ac0c37cef3866caa67d8c64acf4b
BLAKE2b-256 2193c3cdee99a6d9aa87746013c8be2d85a4b9de7b34f3aa9586c126811b42b1

See more details on using hashes here.

File details

Details for the file pymailgen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymailgen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for pymailgen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e482bff3d7026308cecf095fbcc73e714f6b1831875286ca44c6dd19f2150e3
MD5 7afbd727cb7cf6db124cd0fe33404e69
BLAKE2b-256 323db80be2e4911da667ab49672a5e1d59aeb4d29f9cd0c69bcf2153b4d5138a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page