Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
def sendemail():
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
mail_content = 'Welcome to te basketball news and update service'
#The mail addresses and password
adminaddress = 'examtestgaren@gmail.com'
adminpassword = 'PasswordGaren51$'
subscriberaddress = []
maxLengthList = 5
while len(subscriberaddress) < maxLengthList:
item = input("enter 5 emails you want the imformation to be sent to: ")
subscriberaddress.append(item)
#Setup the MIME
message = MIMEMultipart()
message['From'] = adminaddress
message['To'] = ",".join(subscriberaddress)
message['Subject'] = 'Thank you for joining the basketball news and update service' #The subject line
#The body and the attachments for the mail
message.attach(MIMEText(mail_content, 'plain'))
#Create SMTP session for sending the mail
session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
session.starttls() #enable security
session.login(adminaddress, adminpassword) #login with mail_id and password
text = message.as_string()
session.sendmail(adminaddress, subscriberaddress, text)
session.quit()
print('The email has been sent')
User=int(input(" Would you like to subscribe to my basketball news and score update service where we send updates once a day. if yes press 1 if no press 0"))
if User == 1:
print("ok")
sendemail()
else:
print("Thank you, Goodbye")
quit()