I am trying to make a super simple email client. This will enable me to send emails from school to my home computer because they have outlook and gmail blocked. When i try to run it, it says: TypeError: get() missing 1 required positional argument: 'index1' I have replaced my email and password with asterix's for security purposes. Thanks in advance :)
Heres my code:
from tkinter import *
import tkinter as tk
from email.message import EmailMessage
import smtplib
window=Tk()
window.title('Email Client')
window.geometry('200x275')
textbox2=Text(window,width=20,height=10,bg='light grey')
label2=Label(window,text='Message')
textbox1=Text(window,width=20,height=1,bg='light grey')
label1=Label(window,text='Subject')
def email_alert(subject, body, to):
msg = EmailMessage()
msg.set_content(body)
msg['subject'] = subject
msg['to'] = to
user = "*******************"
msg['from'] = user
password = "*************"
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(user, password)
server.send_message(msg)
server.quit()
if __name__ == '__main__':
def Send():
dialog = textbox1.get()
subject = textbox2.get()
email_alert(subject, dialog, "******************")
label1.pack()
textbox1.pack()
label2.pack()
textbox2.pack()
button1=Button(window,text='Send Email',width=10,height=1, command=Send)
button1.pack()
window.mainloop()