#!/bin/python3 import sqlite3 import smtplib import constants username = constants.EMAIL_USERNAME password = constants.EMAIL_PASSWORD conn = sqlite3.connect('mailing_list') cursor = conn.cursor(); mails = cursor.execute('SELECT email FROM mails') def handle(new_grades): fromaddr = username server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(username, password) msg = new_grades for email in mails: toaddr = email server.sendmail(fromaddr, toaddr, msg) server.quit() conn.close()