How I built an awesome email-marketing Command Line App with TypeScript
Tags: showdev, typescript, node
Published: 2020-01-01 11:15:57

{% github https://github.com/KumarAbhirup/bulk-mail-cli %}

> I just created [bulk-mail-cli](https://github.com/KumarAbhirup/bulk-mail-cli) and this post demonstrates how and why I created it.

# What is [bulk-mail-cli](https://github.com/KumarAbhirup/bulk-mail-cli)?

{% twitter 1212318232561848321 %}

{% twitter 1212318235539861504 %}

{% twitter 1212318247225155585 %}

{% twitter 1212318251755065344 %}

{% twitter 1212318253495681024 %}

I hope the tweets above give a fair idea about what bulk-mail-cli is.

# Journey

Being a student, I wasn't able to afford MailChimp and MailGun. Also the fact that creating `bulk-mail-cli` will do good to my portfolio. 

So, I created the tool by myself which has all the important features that MailChimp has. _Except the Mail Analytics feature. I am currently building it into the CLI._

I created v1 of `bulk-mail-cli` in Jan 2019. [See on Product Hunt](https://www.producthunt.com/posts/bulk-mail-cli). 

Since then, I got a decent number of people (20-25) to use it on a regular basis. 

I also got a lot of emails about suggestions to improve it.

There were important features missing... 

Like for example, Configuration of time interval to wait for each consequent email to send.

Also, there was no way to send attachments to the email list.

Also, the CLI did not run on cloud servers. It is necessary that these CLI tools run on Cloud so that the tool usage can be automated by the users.

Few feedbacks I received 👇

{% github https://github.com/KumarAbhirup/bulk-mail-cli/issues/19#issuecomment-480658002 %}

{% github https://github.com/KumarAbhirup/bulk-mail-cli/issues/14#issuecomment-446464305 %}

## And I started creating...

I created the `v2` in a week or two in my Highschool Xmas Vacations.

In the meanwhile, I also shared what I learned about creating Command Line Apps in the below DEV posts.

If you wanna learn how to create CLIs, the Starter Blogpost of mine might help :)

{% post https://dev.to/kumar_abhirup/a-starter-guide-to-create-a-command-line-app-in-node-js-41hn %}

> Now that the `v2` is out... You can use it on everyday basis and you can also read all the code in [this GitHub Repository](https://github.com/KumarAbhirup/bulk-mail-cli/). The repository contains documentation about how to use it.

> Install `bulk-mail-cli` 👉 `npm i -g bulk-mail-cli` and type `bulkmail` in the terminal for support.

# Features

💃 **Active on Slack.** Join the [bulk-mail-cli Slack group](http://bit.ly/bulkmailcli) for suggestions, bugs reports, support, and core development.

📦 **Shoot mails using CSV**.

📝 Mail **dynamic HTML Templates** using the `{{fname|lname}}` syntax.

⏰ Set the sending **interval time** in Cron Expressions! Eg. `*/10 * * * * *`

📌 **Unlimited attachments!** Attach any files on your local computer or you may just provide a direct URL in configuration and `bulk-mail-cli` will download and send the attachment under dynamic filenames and pathnames.

⛅️ **Runs on cloud!** Can be run on AWS EC2 servers and on any Node.js droplet on DigitalOcean.

🔰 **It saves your campaign progress!** You can pause and resume the Mail Campaign from where you left the last time.

✨ **Use .env variables** to not hardcode the emails and passwords in configuration files.

👨‍🏫 **Contentful demo files provided!** You get many beautiful email templates to pick from!

𝔀 **WordPress and other CMS' friendly.** Just export the list of your users, change the email containing column name to `email` and you are good to go!

🧪 **Tested on MacOS and Linux**.

# Technologies and Libraries used

- TypeScript
- Nodemailer
- SimpleSmpt
- csvtojson
- ncp

The complete app is only based on [nodemailer](https://www.npmjs.com/package/nodemailer) yet does so much!

## Read the code

[This is the prime file that runs bulk-mail-cli](https://github.com/KumarAbhirup/bulk-mail-cli/blob/master/src/cli/start.ts). Please take time to read it and you'll understand how straight forward the process is, to create a CLI.


---

Thank you for reading this post! 

Make sure you try out `bulk-mail-cli`... If you spot bugs/errors, please DM me on [Twitter (@kumar_abhirup)](https://twitter.com/KumarAbhirup)... The tool is tested on MacOS and Linux. If you are a Windows user, please let me know if things are working fine there!

{% user kumar_abhirup %}

# About me

**I am Kumar Abhirup, a 16-year-old JavaScript React developer from India who keeps learning a new thing every single day.**

[Connect with me on Twitter 🐦](https://twitter.com/kumar_abhirup)
[My personal website and portfolio 🖥️](https://kumar.now.sh)

_Comment below your better ways, and suggestions to improve this article. :)_