One of the biggest problems bloggers, solopreneurs and startups face is to keep their users engaged. One of the best ways to do this is to send them useful mail.I have been using Mailchimp to send out mails for a little more than 6 years now. And I absolutely love and recommend their service. The free plan allows about 2000 subscribers. Fortunately(or unfortunately) my mailing lists will reach that number very soon. Once the number does exceed 2000 you have two choices:
- Upgrade my plan
- Use another service
> Upgrading: upgrading my plan to 2500 subscribers would cost me about $30 a month. :3
> Other services: other email marketing solutions in the market do not meet my requirement: free/cheap.
In this post, I will describe how you can do this without spending a lot of money.
What we need to handle our own mailing lists
- Database to store our mailing lists
- A mailing server
1. Database
We will be using Google sheets as our database.
Why Google Sheets?
- Simple to use and update
- Up to 5 million cells
- Number of Tabs: 200 sheets per workbook
- FREE
Need I say more?
For us to interact with our database/sheet, we will need to create an API. If you have no clue about what an API is or how to make one, I suggest you read my blog post on creating REST APIs with flask.We will need to make APIs for two things.
- inserting an email to the mailing list
- getting all the emails from the mailing list
Connecting with Google Sheets
First let us get our google credentials. Go to this page and enable Google Sheets API. Once done, you should be able to download your Google API credentials. If you haven’t worked with Google APIs before I recommend you to follow the steps on that page.
Reading the data:
Writing new data:
For this we will be using the Sheets append API
Writing our APIs
If you haven’t already read my – simple guide to creating REST API’s with flask, you should. Converting the above functions into a flask API we get:
Let’s test our APIs.
Everything seems to be working fine, so let’s move on to the next bit –
The mailing server
The mailing server will send your emails to your subscribers. You can use any service like SNS, sendgrid or getresponse, but for the purposes of this post I’ll be using mailgun. Sending an email on mailgun –
Putting it all together
To host the flask app for free you can use heroku.
Test the running version of the app here.
If you want to put your own email address and test it then just insert your email address in the following address.
https://email-sheets-api.herokuapp.com/subscribe?email=yourEmail@gmail.com
If you have any questions regarding this post, feel free to ping me @Ashish_che