diff --git a/python/reissue_book/Library_college.py b/python/reissue_book/Library_college.py index a53643e..80d0ba5 100644 --- a/python/reissue_book/Library_college.py +++ b/python/reissue_book/Library_college.py @@ -6,13 +6,18 @@ import json import os import sys +from mailer import send - +#reading and saving user's information for authentication def user_auth(): username=input('Enter username(reg. no.):-') password=getpass.getpass('Enter password:-') + email=input('Enter your email address:-') + emailpass=getpass.getpass('Enter email password:-') data={'username':username, - 'password':password} + 'password':password, + 'email':email, + 'emailpass':emailpass} with open('data.json','w') as outfile: json.dump(data,outfile) @@ -105,6 +110,8 @@ def user_auth(): else: print('RETURN NEEDED !!!') print('You need to return ""'+book[i].text+'"" today. ') + #function to send self-reminder in user's email + send() #closing browser/webdriver browser.close() diff --git a/python/reissue_book/__pycache__/mailer.cpython-36.pyc b/python/reissue_book/__pycache__/mailer.cpython-36.pyc new file mode 100644 index 0000000..12456e8 Binary files /dev/null and b/python/reissue_book/__pycache__/mailer.cpython-36.pyc differ diff --git a/python/reissue_book/mailer.py b/python/reissue_book/mailer.py new file mode 100644 index 0000000..0e9d75e --- /dev/null +++ b/python/reissue_book/mailer.py @@ -0,0 +1,17 @@ +def send(): + import smtplib + + smtp = smtplib.SMTP('smtp.gmail.com',587) + + smtp.starttls() #starting transport layer security + + with open('data.json') as json_file: + data = json.load(json_file) + + smtp.login(data['email'],data['emailpass']) + + message = "Self reminding for library book reissue" + + smtp.sendmail(data['email'],data['email'], message) + + smtp.quit() \ No newline at end of file