-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemailreminder.py
More file actions
77 lines (62 loc) · 2.55 KB
/
emailreminder.py
File metadata and controls
77 lines (62 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from tkinter import *
import smtplib
#main screen
master = Tk()
master.title("Custom Python Email App")
#functions
def send():
try:
username = temp_username.get()
password = temp_password.get()
to = temp_receiver.get()
subject = temp_subject.get()
body = temp_body.get()
if username =="" or password =="" or to =="" or subject =="" or body =="":
notif.config(text = "All fields required",fg ="red")
return
else:
finalMessage = 'Subject: {}\n\n{}'.format(subject,body)
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login(username,password)
server.sendmail(username,to,finalMessage)
notif.config(text = 'Email has been sent', fg ='green')
except:
notif.config(text="Error sending email", fg="red")
def reset():
usernameEntry.delete(0,'end')
passwordEntry.delete(0,'end')
receiverEntry.delete(0,'end')
subjectEntry.delete(0,'end')
bodyEntry.delete(0,'end')
#graphics
Label(master, text= "Custom Email App",font=('Calibri',15)).grid(row=0,sticky=N)
Label(master, text= "Use the form below to send an email",font =('Calibri',11)).grid(row=1,sticky= W,padx =5)
Label(master, text= "Email",font =('Calibri',11)).grid(row=2,sticky= W,padx =5)
Label(master, text= "Password",font =('Calibri',11)).grid(row=3,sticky= W,padx =5)
Label(master, text= "To",font =('Calibri',11)).grid(row=4,sticky= W,padx =5)
Label(master, text= "Subject",font =('Calibri',11)).grid(row=5,sticky= W,padx =5)
Label(master, text= "Body",font =('Calibri',11)).grid(row=6,sticky= W,padx =5)
notif = Label(master, text= "",font =('Calibri',11))
notif.grid(row=7,sticky= S,padx =5)
#storage
temp_username = StringVar()
temp_password = StringVar()
temp_receiver = StringVar()
temp_subject = StringVar()
temp_body = StringVar()
#Entries
usernameEntry = Entry(master, textvariable = temp_username)
usernameEntry.grid(row =2,column = 0)
passwordEntry = Entry(master,show = "*", textvariable = temp_password)
passwordEntry.grid(row =3,column = 0)
receiverEntry = Entry(master, textvariable = temp_receiver)
receiverEntry.grid(row =4,column = 0)
subjectEntry = Entry(master, textvariable = temp_subject)
subjectEntry.grid(row =5,column = 0)
bodyEntry = Entry(master, textvariable = temp_body)
bodyEntry.grid(row =6,column = 0)
#button
Button(master, text ='send', command = send).grid(row =7,sticky =W,pady=15,padx = 5)
Button(master, text ='Reset', command = reset).grid(row =7,sticky =W,pady=45,padx = 45)
master.mainloop()