My Newsletter

Flask and Redis based newsletter system

: python

Concepts Used

  • SMTP
  • Web Frameworks
  • REST


  • Clean and Pretty UI
  • Email Validation
  • Quick Publish

Code Link


I maintain a few blogs on various topics and I needed a system to send a weekly/monthly newsletter with a curated list of posts.

For that purpose I made a Flask app to publish, manage and generate a newsletter.


It uses the Flask Microframwork as a base. I have given it access to my email id ([email protected]) to connect with SMTP provided by Zoho.

All the email creds are stored as environment vars in Heroku.

It uses a Redis database to store the users and their emails in a Hash datatype.

The app uses various steps to authenticate the emails, using:

  • Google Captcha
  • Trumail API : A service which reports invalid emails.
  • Click-to-validate in email system

The data for the latest newsletter is stored at a different location, for easy updation, in Json format.

The app, on publish trigger, accesses the json and converts the data to be rendered into the template.

The newsletter email template is rendered using the feature rick Jinja 2 templating language.

At the same time, the user data is drawn out too, and added to individual emails, with details like name and email.

Then they all are sent sent using the Flask_mail module.

I use the urls, to get basic info , also to publish the latest newsletter.


The App has the following features:

  • Multi Level Email Validation
  • API endpoints to control the app
  • Using Json to store newsletter data
  • Using Environment Vars to hide sensitive info
  • Option to Unsubscribe


I learnt alot about:

  1. SMTP
  2. Programmatic email sending
  3. Custom domain email
  4. Python Environment Vars