Author: Will McIntyre
Date: 2023-09-07
This script encapsulates the back-end database management/editing, quote API fetching and email sending of the Mindfuel web app.
Mindfuel is a web application designed to inspire and motivate its users with daily quotes delivered to their inbox. This Python script automates the process by fetching motivational quotes from the ZenQuotes API and sending them to subscribers via email.
See below for an example of the email template:
Note: click here to subribe to the official Mindfuel quote emails.
-
Subscriber Management: Allows you to add and delete subscribers to/from the mailing list.
-
Status Display: Provides information about the current status of the mailing list (development or production environment and email address display)
-
Email Sending: Sends inspirational quotes from a configured email address to all subscribers on the mailing list from a secure SSL/TLS-encrytped connection.
To run the Mindfuel Quote Emailer, follow these steps in bash:
-
Clone or download this repository to your local machine and navigate to quote-emailer directory:
git clone https://github.com/will-mcintyre04/quote-emailer.git cd quote-emailer -
Install all required dependancies into your local environment:
pip install -r requirements.txt
-
Create a .env file in your local directory
touch .env
-
Configure mailing and database environment
First, confiugure the local database environment (development produces a local db)
python motivation_mailer.py -db dev
Make sure to create a google application password for the sending email address.
Finally, setup the email environment within the script (replacing YOUR_ADDRESS and YOUR_APP_PASS) with the sending address and app password created previously.python motivation_mailer.py -a YOUR_ADDRESS python motivation_mailer.py -p YOUR_APP_PASS
-
Run the script using the following commands:
python motivation_mailer.py [options]
Replace [options] with any of the following command-line options:
-h, --help show this help message and exit --status, -s Displays configuration environment and lists all subscribers --add ADD [ADD ...], -a ADD [ADD ...] Email address(es) to add to database --delete DELETE [DELETE ...], -d DELETE [DELETE ...] Email address(es) to delete from database --database DATABASE, -db DATABASE Sets database configuration ('production' or 'development') --email EMAIL, -e EMAIL Sets the sending email address --password PASSWORD, -p PASSWORD Sets the sending email password --send Sends emails to the emails stored in the db
