Permalink
Cannot retrieve contributors at this time
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?
Resit-project-/IMp321.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (35 sloc)
1.59 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |