Comment créer une application qui envoie des e-mails dans Python

import smtplib
import random
from email.message import EmailMessage


subject = input("Subject: ")
body = input("Text: ")
to = input("Send to: ")



if __name__ == '__main__':
    msg = EmailMessage()
    msg.set_content(body)
    msg['subject'] = subject
    msg['to'] = to


    sender = input("Sender: ")
    print("""To know your app password which you'll need you need to go to your sender gmail's account 
then click on the account icon on the top right then chose manage your account 
and chose security then go to signing to google and activate 2 step verification 
after filling the information needed go back to the same page and click on app passwords 
click select and choose other and type email then click done and save your app password
    """)
    password  = input("App password: ")
    msg['from'] = sender

    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    server.login(sender, password)
    server.send_message(msg)

    server.quit()

    print("Email sent")


Karim Radwan