pynotify
A Python package built to send email notifications which can be integrated into any existing piece of python software.
Features
Sends a simple email with a subject and a message body.
send_email(destinaiton, subject=" ", msg=" "): ''' Arguements: destination: Takes in destionation email of type string subject(optional arguement): Takes in a string as an input (Default arg: None) msg(optional arguement): Takes in a message of type string as input (Default arg: None) '''
Sends an email with attachment(s) included.
send_email_with_attachment(destination, files, sub="Subject", text= "No text"): ''' Arguements: destination: Takes in destionation email of type string files: Take in a list of strings as input sub(optional arguement): Takes in a string as an input (default arg empty) text(optional arguement): Takes in a message of type string as input (default arg empty) '''
Usage
Make sure you have Python 3.6 or 3.7 installed. Then, import the library from TestPyPi (Test Python Packaging Index)
pip install -i https://test.pypi.org/simple/ pynotify
A demo script of this in action is shown below
from pynotify import send_email, send_email_with_attachmentsubject = "Killer Robot"message = "Hi there!"dest = "[email protected]" # add your email here# attachment paths are stored in an arrayimage = ["cat.jpg"] # for one fileimages = ["cat.jpg", "dog.jpg"] # for multiple files# sends an emailsend_email(dest, "Hello!")# sends an email with attachementssend_email_with_attachment(dest, images, subject, message)
Takeaways
- Program written in Python 3.6
- Nothing here. What did you expect? A cookie!?
- Need to update dummy google account to less secure if not used for a long time, as google automatically shuts it down!
Author
Made with