Sep-28-2022, 09:14 PM
I got it to work.
Apparently he message body didn't like being inside the function because it was tabbed out so I put it at the top of my code as a variable so I didn't have to tab it out and now it works as it should and the emails display properly.
This displays it properly.
Apparently he message body didn't like being inside the function because it was tabbed out so I put it at the top of my code as a variable so I didn't have to tab it out and now it works as it should and the emails display properly.
This displays it properly.
#------------------------------------------------------------------------------------- # Define Variables #------------------------------------------------------------------------------------- console = Console(width=100) #E-mail display format for E-Mail Function emailFormat = """\ From: "Baxter" Subject: Alert! """ #------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------- # E-Mail Function #------------------------------------------------------------------------------------- def sendEmail(): #Tutorial Link: https://www.abstractapi.com/guides/sending-email-with-python #Define the transport variables ctx = ssl.create_default_context() password = "12345" sender = "[email protected]" autoTypeAnimation('Who should I send the E-mail to?') receiver = UserInput() autoTypeAnimation('What should I say?') msg = UserInput() #Preview the E-mail print("\n[green]Baxter: [/green]") print(emailFormat + msg + "\n") #Send Email try: with smtplib.SMTP_SSL("smtp.gmail.com", port=465, context=ctx) as server: server.login(sender, password) server.sendmail(sender, receiver, emailFormat + msg) autoTypeAnimation('E-mail sent') except: autoTypeAnimation('E-mail failed to send') #-------------------------------------------------------------------------------------