Reputation: 11
I am trying to add a system in which a user puts in their name, email, and question. I keep getting the following error:
This is the error i am getting when i run the script.
python techsupport.py
Exception in Tkinter callback
Traceback (most recient call last):
File C:\__init__.py, line 1699 in __call__ return self.func(*args)
File C:\smtplib.py, line 867, in sendmail raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (501, b'5.5.4 Invalid arguments', [email protected]')
NOTE: the smtp server and the port are correct. I just have not put them in here for security reasons.
Here is the current code:
from tkinter import *
from tkinter import ttk
import smtplib
import os
import mimetypes
from tkinter import messagebox
import tkinter.messagebox as tm
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
def submit_command():
if (user_fname.get() and user_lname.get() and user_email.get()):
email_user = user_email.get()
email_send = '[email protected]'
subject = "Tech Support"
msg = MIMEMultipart()
msg['From'] = email_user
msg['To'] = email_send
msg['Subject'] = subject
body = t1.get('1.0', END)
text = msg.as_string()
server = smtplib.SMTP('ServerIP', Port)
server.starttls()
server.sendmail(email_user, email_send, text, body)
server.quit()
print(email_user + '\n' + email_send + '\n' + text + '\n' + body)
messagebox.showinfo("Thank You...","Your request has been sent. We will get back to you as soon as we can!")
tech.destroy()
else:
messagebox.showinfo("Missing Fields", "You must fill in all fields...")
tech = Tk()
tech.configure(background='grey15')
tech.title("Technical Support Ticket")
tech.iconbitmap('img.ico')
width = 350
height = 450
screen_width = tech.winfo_screenwidth()
screen_height = tech.winfo_screenheight()
x = (screen_width/2) - (width/2)
y = (screen_height/2) - (height/2)
tech.geometry("%dx%d+%d+%d" % (width, height, x, y))
tech.resizable(0, 0)
l1 = Label(tech, text="First Name...")
l1.pack(padx=2, pady=2)
user_fname=StringVar()
e1 = ttk.Entry(tech, textvariable=user_fname)
e1.pack(padx=2, pady=2)
l2 = Label(tech, text="Last Name...")
l2.pack(padx=2, pady=2)
user_lname=StringVar()
e2 = ttk.Entry(tech, textvariable=user_lname)
e2.pack(padx=2, pady=2)
l3 = Label(tech, text="Email Address...")
l3.pack(padx=2, pady=2)
user_email=StringVar()
e3 = ttk.Entry(tech, textvariable=user_email)
e3.pack(padx=2, pady=2)
l4 = Label(tech, text="Explain in detail what the issue is.")
l4.pack(padx=2, pady=2)
t1 = Text(tech, wrap=WORD, height=1)
t1.pack(fill=BOTH, expand=1, padx=2, pady=2)
b1 = Button(tech, text="Submit", width=12, command=submit_command)
b1.pack(padx=5, pady=5)
tech.mainloop()
Is there something im doing wrong, or something im missing?
Thanks!
Upvotes: 0
Views: 1218
Reputation: 370
The 501 code returned from the SMTP server says that the email you sent along is no good. I'm assuming since you got that error, then connections are ok, but the server rejected your email.
This could happen if the email is recognized as spam or if the server was unable to convert it to a fully qualified email address.
The email in your error looks like one that could be rejected, so perhaps change your email.
Upvotes: 1