0

I am trying to make my own "email interface", in which I need to gather the inputs from the user via the entry boxes, to use them in the email sending process. The problem is that the .get() feature always seems to error.

line 32, in send_it email_resipient = Three.get()
AttributeError: 'NoneType' object has no attribute 'get'

Please help, I have been researching for hours, and I can't seem to find a fix. Here's the code....

from tkinter import *
import smtplib


root = Tk()
root.title("Jon's Email Service")
root.geometry("800x640+0+0")

Label(root, text="Jon's Email Service", font=("arial", 60, 
"bold"), fg="black").pack()

Label(root, text="User's Email address {Has to be gmail} ", 
font=("arial", 20,), fg="black").pack()

One = Entry(root,width=40, bg="white").pack()


Label(root, text="User's Gmail Password", font=("arial", 20,), 
fg="black").pack()

Two = Entry(root, width=40, bg="white").pack()



Label(root, text="Email Recipient", font=("arial", 20,), 
fg="black").pack()

Three = Entry(root,width=40, bg="white").pack()
Label(root, text="The Message", font=("arial", 20,), 
fg="black").pack()

Four = Entry(root, width=60, bg="white").pack()

def send_it():
    email_resipient = Three.get()
    emailUser = One.get()
    user_Password = Two.get
    msg = Four.get()
    print(emailUser)
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    server.login(emailUser, user_Password)
    server.sendmail(emailUser, email_resipient, msg)
    server.quit()
Label(root, text="Email Is Sent!", font=("arial", 20,), 
fg="black").pack()

send = Button(root, text="Send", width = 40, bg = "lightblue", 
command = send_it).pack()

root.mainloop()
Jon
  • 29
  • 3
  • `Three` doesn't actually refer to your `Entry` object. You have it as the return of `pack`, which is `None`. Remove `pack` from that line, and pack in a new line. – busybear Jan 01 '19 at 03:18

1 Answers1

0

You should not use .pack() at the end of assignment string, you should first assign variable, then .pack() it:

from tkinter import *
import smtplib


root = Tk()
root.title("Jon's Email Service")
root.geometry("800x640+0+0")

Label(root, text="Jon's Email Service", font=("arial", 60, 
"bold"), fg="black").pack()

Label(root, text="User's Email address {Has to be gmail} ", 
font=("arial", 20,), fg="black").pack()

One = Entry(root,width=40, bg="white")
One.pack() #here

Label(root, text="User's Gmail Password", font=("arial", 20,), 
fg="black").pack()

Two = Entry(root, width=40, bg="white")
Two.pack() # here 

Label(root, text="Email Recipient", font=("arial", 20,), 
fg="black").pack()

Three = Entry(root,width=40, bg="white")
Three.pack() # here
Label(root, text="The Message", font=("arial", 20,), 
fg="black").pack()

Four = Entry(root, width=60, bg="white")
Four.pack() # here

def send_it():
    email_resipient = Three.get()
    emailUser = One.get()
    user_Password = Two.get
    msg = Four.get()
    print(emailUser)
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    server.login(emailUser, user_Password)
    server.sendmail(emailUser, email_resipient, msg)
    server.quit()
Label(root, text="Email Is Sent!", font=("arial", 20,), 
fg="black").pack()
send = Button(root, text="Send", width = 40, bg = "lightblue", 
command = send_it).pack()

root.mainloop()

The variable gets the return value of pack() function, not actually a Entry or whatever, and the return of pack() is None.

BladeMight
  • 2,670
  • 2
  • 21
  • 35