Skip to content
Permalink
Browse files
Update news-service.py
  • Loading branch information
kpakolj committed Aug 27, 2019
1 parent 17cd4ba commit 9fe13c21a7ddff9ac895a04a86c83abc0ece5ba3
Showing 1 changed file with 8 additions and 7 deletions.
@@ -4,7 +4,7 @@ port = 465 # For SSL #got this line from https://realpython.com/python-send-e
# Create a secure SSL context
context = ssl.create_default_context() #got this line from https://realpython.com/python-send-email/

receiver_list = ["receiveremail@gmail.com"]
receiver_list = ["kpakolj@coventry.ac.uk","justicetkpakol1@gmail.com"]


def password():
@@ -23,14 +23,15 @@ def message():
"""+news() #got this line from https://realpython.com/python-send-email/
return message

def send(gmail_id, message):
def send(gmail_id, password,message):
for receiver_email in receiver_list:
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: #got this line from https://realpython.com/python-send-email/
server.login(gmail_id, password)
server.sendmail(gmail_id, receiver_email, message) #got this line from https://realpython.com/python-send-email/

def login(gmail_id):
def login(gmail_id,password):
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: #got this line from https://realpython.com/python-send-email/
server.login(gmail_id, password()) #got this line from https://realpython.com/python-send-email/
server.login(gmail_id, password) #got this line from https://realpython.com/python-send-email/

def remove():
n=int(input("Enter the number of email_ids you want to remove from the receivers' list"))
@@ -59,11 +60,12 @@ def add():
def main():
enter= input("Press any button to login \n")
gmail_id=input("Please enter your gmail_id and press enter: ")
login(gmail_id)
password_=password()
login(gmail_id,password_)
while (True):
menu=input("Welcome back, "+gmail_id+"\nIf you want to send an email to your subscribers, press 1 then press enter\nIf you want to add to the subscribers' list, press 2 then press enter\nIf you want to delete from the list, press 3 \nIf you want to exit, press 4 ")
if menu=="1":
send(gmail_id,message())
send(gmail_id,password_,message())
elif menu=="2":
add()
elif menu=="3":
@@ -77,4 +79,3 @@ def main():


main()

0 comments on commit 9fe13c2

Please sign in to comment.