Skip to content
Permalink
Browse files
Update index.py
  • Loading branch information
johala9 committed Mar 31, 2021
1 parent a139f00 commit 7030242ec312366b644cd997244b1337d23f5926
Showing 1 changed file with 14 additions and 8 deletions.
@@ -9,6 +9,14 @@ from email.message import EmailMessage
#allows searching of directory (os is for Miscellaneous operating system interfaces)
import os

def loginEmail(adminEmail, adminPass):
# Log into GMail server with admin/dev email (created bespoke for this proj)
server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
server.login(adminEmail, adminPass)

return server


#email_sender function
def email_sender(subsFile, articlesFile, announceFile, adminEmail, adminPass):
# Pull out everything in excel file
@@ -33,7 +41,7 @@ def email_sender(subsFile, articlesFile, announceFile, adminEmail, adminPass):
else:
# Repeat if other statments arent met
continue
# Subject is set
# Subject is sets

# TEMPLATE FILE TO BE USED DEPENDING ON SUBJECT/TYPE
if emailTypeIn == 1:
@@ -65,10 +73,8 @@ def email_sender(subsFile, articlesFile, announceFile, adminEmail, adminPass):

# msg.add_header(subject,'text/html')
msg['Subject'] = subject

# Log into GMail server with admin/dev email (created bespoke for this proj)
server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
server.login(adminEmail, adminPass)

server = loginEmail(adminEmail, adminPass)

# Allows correct indexing of arrays pulled from excel
counter = 0
@@ -90,13 +96,13 @@ def email_sender(subsFile, articlesFile, announceFile, adminEmail, adminPass):
#msg to admin to show that process is complete
print("DONE")

# USER: CHANGE THESE VARIABLES BEFORE FUNCTION CALL
# Change to whatever directory you are using
subsFile = r"C:\Users\arunj\Documents\UniWork\Python\RESIT\subscribers.xlsx"
articlesFile = r"C:\Users\arunj\Documents\UniWork\Python\RESIT\templates\ARTICLES"
announceFile = r"C:\Users\arunj\Documents\UniWork\Python\RESIT\templates\ANNOUNCEMENTS"

# REPLACE WITH EMAIL/PASS
adminEmail = "@gmail.com"
adminPass = ""
adminEmail = "arunjohal.email.dev@gmail.com"
adminPass = "Password_21"

email_sender(subsFile, articlesFile, announceFile, adminEmail, adminPass)

0 comments on commit 7030242

Please sign in to comment.