Open Kolbynko opened 2 years ago
import email,smtplib,ssl from string import Template from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText
finalTemplate=""
templateName1="Template 1.txt" templateName2="Template 2.txt" templateName3="Template 3.txt" templateName4="Template 4.txt"
def createTemplate(template): with open(template, 'r', encoding='utf-8') as template_file: template_file_content = template_file.read() return Template(template_file_content)
def templatePicker(v_kontakte, ockovany, vysledok_testu): if v_kontakte and ockovany: finalTemplate=createTemplate(templateName1)
elif v_kontakte==False and vysledok_testu==False: finalTemplate=createTemplate(templateName2)
elif vysledok_testu: finalTemplate=createTemplate(templateName3)
elif v_kontakte and ockovany==False: finalTemplate=createTemplate(templateName4)
else: print("Creating template - FAILED")
return finalTemplate
def createMessage(name, email):
s = smtplib.SMTP(host="MartinKollar@s.zochova.sk", port=587) s.starttls() if (s.login("MartinKollar@s.zochova.sk", "Zochova2244")): print("SMTP connection - OK") else: print("SMTP connection - FAILED")
msg = MIMEMultipart() #creates a message
message = finalTemplate.substitute(PERSON_NAME=name.title())
msg['From']="MartinKollar@s.zochova.sk" msg['To']=email msg['Subject']="Covid-Informator"
msg.attach(MIMEText(message, 'plain'))
s.send_message(msg)
del msg
createMessage("Tomas", "bubeniktomi@gmail.com")
print("1 = bez kontaktu s pozitívnym") print("2 = kontakt s pozitívnym") print("3 = pozitívny test")
x = input("Zadajte číslo podla tvojej situacie: ") if x=="1":print('Nič sa nedeje') elif x=="2":print('Sprav si ag test') elif x=="3":print('14 dní karanténa4') else:print("Zadal si nespravny argument")