-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
84 lines (66 loc) · 2.56 KB
/
main.py
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
78
79
80
81
82
83
84
from ast import Str
from http import server
import tkinter
from tkinter import *
import smtplib
from tokenize import String
#Main screen
obj=Tk()
obj.title('Custom E-mail 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 are required to be fill up ...",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.send(username,to,finalMessage)
notif.config(tetx='Email has been sent ',fg="green")
except:
notif.config(text='Error in sending email',fg="green")
def Reset():
usernameEntry.delete(0,'end')
passwordEntry.delete(0,'end')
receiverEntry.delete(0,'end')
subjectEntry.delete(0,'end')
bodyEntry.delete(0,'end')
#Graphics
titleLabel=Label(obj,text="Custom E-mail App",font=('Calibri',15)).grid(row=0,sticky=N)
Label(obj,text="Use the form below to send an email",font=('Calibri',11)).grid(row=1,sticky=W,padx=5)
Label(obj,text="Email",font=('Calibri',11)).grid(row=2,sticky=W,padx=5)
Label(obj,text="Password",font=('Calibri',11)).grid(row=3,sticky=W,padx=5)
Label(obj,text="To",font=('Calibri',11)).grid(row=4,sticky=W,padx=5)
Label(obj,text="Subject",font=('Calibri',11)).grid(row=5,sticky=W,padx=5)
Label(obj,text="Body",font=('Calibri',11)).grid(row=6,sticky=W,padx=5)
notif=Label(obj,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(obj,textvariable=temp_username)
usernameEntry.grid(row=2,column=0)
passwordEntry=Entry(obj,show="*",textvariable=temp_password)
passwordEntry.grid(row=3,column=0)
receiverEntry=Entry(obj,textvariable=temp_receiver)
receiverEntry.grid(row=4,column=0)
subjectEntry=Entry(obj,textvariable=temp_subject)
subjectEntry.grid(row=5,column=0)
bodyEntry=Entry(obj,textvariable=temp_body)
bodyEntry.grid(row=6,column=0)
#Buttons
Button(obj,text="Send",command=Send).grid(row=7,sticky=W,pady=15,padx=5)
Button(obj,text="Reset",command=Reset).grid(row=7,sticky=W,pady=45,padx=45)
obj.mainloop()