companies.append(database.Company(testcomp4)) #add the companies to the list of companies to send emails to for company in companies: if company.tte_days in email_txts.keys(): email_txts[company.tte_days]['company'].append(company) for days in email_txts: for rec in email_txts[days]['company']: sender.add_recepient(rec.email) sender.set_message_from_txt(email_txts[days]['txt']) sender.send_email() sender.clear_recepients() sender.clear_message() ''' with open('2wks.txt') as m: msgtxt = m.read() print(f'{repr(msgtxt)}') message = EmailMessage() try: server = smtplib.SMTP_SSL(smtphost, 465) server.ehlo() server.login(sender_email, sender_pw) print(f"Success in connecting to {smtphost}")