Sep-26-2022, 11:12 AM
Hello,
I have a sendEmail Function for my voice assistant which allows it to send emails. The emails send successfully, but they don't display properly on the receiver end (The subject line and body don't display).
I want the user to enter the recipient's e-mail and the e-mail's body/message/content (The Subject and From lines are pre-filled so when the receiver gets the email it should show like the screenshots below), but every time I test it out with user input, the e-mail displays without a subject line or message.
Any way to fix this?
Thanks in advance.
With the code I want to use (this one), the E-mails show without a subject or a body:
I have a sendEmail Function for my voice assistant which allows it to send emails. The emails send successfully, but they don't display properly on the receiver end (The subject line and body don't display).
I want the user to enter the recipient's e-mail and the e-mail's body/message/content (The Subject and From lines are pre-filled so when the receiver gets the email it should show like the screenshots below), but every time I test it out with user input, the e-mail displays without a subject line or message.
Any way to fix this?
Thanks in advance.
With the code I want to use (this one), the E-mails show without a subject or a body:
#------------------------------------------------------------------------------------- # E-Mail Function #------------------------------------------------------------------------------------- def sendEmail(): # 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() message = """\ From: "Baxter" Subject: Alert! """ + msg #Send Email with smtplib.SMTP_SSL("smtp.gmail.com", port=465, context=ctx) as server: server.login(sender, password) server.sendmail(sender, receiver, message) autoTypeAnimation('E-mail sent') #-------------------------------------------------------------------------------------The Email's Display properly with this code (But the user won't be able to enter any information in):
import smtplib import ssl from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText # Define the transport variables ctx = ssl.create_default_context() password = "12345" sender = "[email protected]" receiver = "[email protected]" message = """\ From: "Baxter" Subject: Alert! Hello Commander, This is a test. """ with smtplib.SMTP_SSL("smtp.gmail.com", port=465, context=ctx) as server: server.login(sender, password) server.sendmail(sender, receiver, message)