Project #6: Mail Merge for Linux Bash

Project #6: Mail Merge for Linux Bash

Peter Thaleikis

Peter Thaleikis

Engineer. Maker. Open Source Fan. Backpacker

by Peter Thaleikis

Occasionally, I get the feeling that not everything I build needs to be a commercial project. While sustainability is an issue, I still believe there is a realm for free and open-source projects. In some cases, the core value provided by a side project doesn't justify the additional work to add payments and the required management infrastructure behind it. Naturally, this leads to a project with less features. But that's fine with me, as I want to solve only a particular problem and don't aim to build an all-encompassing solution with all the whistles and bells.

An alternative path instead of monetizing the project is simply open-sourcing it. This way others can profit from the work done and give back in other forms (e.g. sponsorship, etc.). Open sourcing the source code allows me to disconnect from the feeling I need to make a quick buck from it. Instead, you can give it away for anyone to use and eventually profit in other forms.

For my latest little project, Mail Merge for Linux Bash, I'm following exactly this. With this project I cared really only about one core: feature merging emails and sending them. Existing services are too feature-rich. I wanted something very simple without monthly running costs. So I've built myself a helper script to load a CSV file and fill in a template before triggering a mailto: in Firefox. Chrome should work as well. The project is free for anyone to use.

What you need

While the project itself doesn't have any direct dependencies, your system will need to fulfill some basic requirements:


  1. Fill in your CSV file and name it targets.csv. You can define any number of headers within the file and use them in your template. You should always have at least the following headers: Subject and Email as the script uses these two.
  2. Write your template file and name it template.txt. Within the template file you can use any headers defined in the CSV file. The subject line should always be the first line of the template, followed by two line breaks and should start with Subject:. Please note that you should use all headers in capital letters within the template file. So, Email would be transformed to EMAIL automatically.
  3. Run php generate.php to trigger the merge of the content and the related mailto: commands. You might need to allow these actions to be triggering your provider email (e.g. Gmail).

While working on fine-tuning your template and testing the headers it might pay off to use only one or two lines in your CSV. Once everything is in order, you can run the whole data set.

That's it. No magic involved.

How to get it?

Simply clone the repository using this command:

git clone [email protected]:spekulatius/linux-bash-mail-merge.git


You can support my open source work and the development through Buy me a coffee. Social shares are also appreciated. You can stay tuned for updates and new projects by subscribing to my newsletter.

Did you like this article?

Besides tones of crap, the web also has lots interesting open-source libraries, actually innovative side-projects and awesome free knowledge. Once in a while, I share these awesome web-findings via email. If this sounds like something you are into, subscribe below:

Subscribe today and get insights soon:

Published under the following tags: