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:
- you can inspect the emails before sending them out;
- 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.shscript 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.
Metadata
Release files for pymailgen 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymailgen-0.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymailgen-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / pymailgen-0.1.0.tar.gz
| Download URL | pymailgen-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0ed1b5070e4da8fc99d42dbeb425e67c6ca1452191658fd06c348a9e75ad8db
|
|
BLAKE2b-256 checksum How to use checksums |
2193c3cdee99a6d9aa87746013c8be2d85a4b9de7b34f3aa9586c126811b42b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pymailgen-0.1.0-py3-none-any.whl
| Download URL | pymailgen-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e482bff3d7026308cecf095fbcc73e714f6b1831875286ca44c6dd19f2150e3
|
|
BLAKE2b-256 checksum How to use checksums |
323db80be2e4911da667ab49672a5e1d59aeb4d29f9cd0c69bcf2153b4d5138a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|