This is an automatic translation generated by artificial intelligence. May contain errors.
As part of automating tasks in the office, we have developed a series of scripts to facilitate the sending of mass emails, for example for sending attendance certificates for the Free Culture Days.
Instead of relying on proprietary solutions or external platforms that do not always meet our needs, we chose to build a simple and reusable tool with free software, leveraging tools like Python, Bash, and the Evolution mail client.
What does this system do?
The system starts from a file with a list of recipients, and generates for each one a personalized email with their name, date, and other relevant data. Optionally, it can also attach a PDF automatically generated with the same personalized data (for example, a certificate or a formal letter).
The sending is not done automatically; instead, it opens a composition window in Evolution for each email, allowing review before sending. We see this as an advantage, as it allows us to keep control over the final message, make corrections if necessary, and avoid mass errors.
What makes it useful?
- It is flexible: Templates can be easily adapted to different events or contexts.
- It does not require connection to external services: We do not use third-party services or proprietary APIs.
- It is reviewable: By using Evolution as a client, each email can be reviewed before sending.
- It allows attaching automatically generated documents: Customized PDFs can be created per recipient with an optional header image.
How does it work?
The system is divided into several scripts:
- A script to automatically fill in the messages and PDF content using variables like
{nombre}
,{fecha}
, etc. - A Python script that generates a PDF from plain text and a header image.
- A Bash script that goes through the list of recipients, generates the message, creates the PDF if applicable, and opens a new mail window for each recipient with everything ready to send.
Difficulties encountered
There were some challenges when working with text and PDF formats. For example:
- Ensuring that the header image does not distort the PDF layout.
- Solving errors due to special characters in names or email addresses.
- Ensuring compatibility with Evolution, especially in the data-passing step via command line.
We were also concerned that the process might be too automatic, and we decided that each message should go through review before being sent. This slows down the process but increases reliability.
Where have we used it?
This system has already been used to:
- Send certificates to those who attended events organized by the office.
- Communicate resolutions or letters to multiple recipients in a personalized way.
- Send calls with unique data for each person (dates, links, names, etc.).
Possible improvements
- Send directly from the command line if desired.
- Export the messages as ready drafts in Evolution.
- Add support for attaching multiple files per recipient.
This is a clear example of how the use of free tools can facilitate daily processes in a public institution, without giving up control over the data or the possibility of adapting them to our real needs. In case of doubt with the code, it can be consulted in this GitLab repository, in the automatizacion/correos/
folder.