-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
306 lines (211 loc) · 9 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
from tkinter import *
from tkinter import messagebox as mb
from tkinter import filedialog
from csv import DictReader
import _thread
import send_mail_f
import login
try:
f = open('logs.csv','r')
d = f.read(1024)
f.close()
if d != '':
pass
else:
login.login()
except:
login.login()
def main_loop():
## ----------------------------------------------------------------------
f = open('logs.csv','r')
r = DictReader(f)
global username
global password
for i in r:
username = i['username']
password = i['password']
f.close()
##-----------------------------------------------------------------------
def logout_func():
f = open('logs.csv','w')
f.write('')
win.destroy()
def vald_email():
to = to_e.get()
subject = subject_e.get()
message = mail_text.get(1.0,END)
if '@' in to and '.com' in to:
try:
send_mail_f.send_mail(username,password,to,subject,message)
mb.showinfo('Sent',f'Mail successfuly sent to {to}')
except:
mb.showerror('Connection error','Unable to connect to internet. Please check your internet connection.')
else:
mb.showerror('Error','Invalid Email Address')
def send_mul_mail_loop():
to = to_e.get()
subject = subject_e.get()
message = mail_text.get(1.0,END)
for mail in mail_list:
send_mail_f.send_mail(username,password,mail,subject,message)
mb.showinfo('Sent',f'Mail successfuly sent to {len(mail_list)} people')
load.destroy()
def load_send():
global load
load = Tk()
load.geometry('+200+200')
load.resizable(0,0)
Label(load, text='Sending Mails......',font=('Cambria',13)).pack()
load.mainloop()
def send_mul_mail():
try:
_thread.start_new_thread(send_mul_mail_loop,())
_thread.start_new_thread(load_send,())
except:
mb.showerror('Error','Please attack a CSV file containing emails. for more help refer to info button')
def csv_func():
try:
f = filedialog.askopenfile(initialdir='E:\\', title='Select file to open',)
r = DictReader(f)
global mail_list
mail_list = []
try:
for row in r:
mail_list.append(row['email'])
except:
mb.showerror('Error','Error Reading The CSV File. Please refer to info button for help.')
except:
pass
def about_func():
mb.showinfo('About', 'This is an exclusive distribution of DeeMail created By Hardeep Singh. This application was designed to send emails. This has features like sending emails, sending multiple emails, setting, about. Hope you like the application. Please share your feedbacks.')
def mul_mail_func():
## Log Bg
log_bg.place(x=1000)
log_img.place(x=1000)
log_in_as.place(x=1000)
name.place(x=1000)
## Menu Options
menu_bg.place(x=1000)
mail_b.place(x=1000)
mul_mail_b.place(x=1000)
setting_b.place(x=1000)
about_b.place(x=1000)
cl_l.place(x=1000)
logout_b.place(x=1000)
## Plus Button
plus_button.place(x=1000)
## Compose Email
header_l.place(x=20,y=50)
to_l.place(x=40,y=120)
## To
to_e.place(x=1000)
##Csv
csv_b.place(x=90,y=120)
csv_ab.place(x=270,y=120)
subject_l.place(x=40,y=170)
subject_e.place(x=120,y=170)
mail_text.place(x=40,y=220)
send_b.place(x=300,y=440)
cancel_b.place(x=360,y=440)
send_b['command'] = send_mul_mail
def home_func():
## Log Bg
log_bg.place(x=0,y=33)
log_img.place(x=50,y=50)
log_in_as.place(x=40,y=120)
name.place(x=10,y=145)
## Menu Options
menu_bg.place(x=0,y=32)
mail_b.place(x=10,y=200)
mul_mail_b.place(x=5,y=250)
setting_b.place(x=5,y=300)
about_b.place(x=10,y=360)
cl_l.place(x=250,y=200)
logout_b.place(x=10,y=410)
## Plus Button
plus_button.place(x=370,y=420)
## Compose Email
header_l.place(x=1000)
to_l.place(x=1000)
to_e.place(x=1000)
subject_l.place(x=1000)
subject_e.place(x=1000)
mail_text.place(x=1000)
send_b.place(x=1000)
cancel_b.place(x=1000)
##Mul_mail
csv_ab.place(x=1000)
csv_b.place(x=1000)
def email_func():
## Log Bg
log_bg.place(x=1000)
log_img.place(x=1000)
log_in_as.place(x=1000)
name.place(x=1000)
## Menu Options
menu_bg.place(x=1000)
mail_b.place(x=1000)
mul_mail_b.place(x=1000)
setting_b.place(x=1000)
about_b.place(x=1000)
cl_l.place(x=1000)
logout_b.place(x=1000)
## Plus Button
plus_button.place(x=1000)
## Compose Email
header_l.place(x=20,y=50)
to_l.place(x=40,y=120)
to_e.place(x=90,y=120)
subject_l.place(x=40,y=170)
subject_e.place(x=120,y=170)
mail_text.place(x=40,y=220)
send_b.place(x=300,y=440)
cancel_b.place(x=360,y=440)
send_b['command'] = vald_email
csv_ab.place(x=1000)
bg = '#408080'
win = Tk()
win.geometry('450x487')
win.resizable(0,0)
win.title('DeeMail')
Label(win, text='',bg=bg,width=450,font=('arial black',15,'bold'),relief='groove').pack()
Label(win, text='DeeMail',bg=bg,fg='white',font=('arial black',12,'bold')).place(x=350,y=2)
home_img = PhotoImage(file='resources/home.png')
Button(win, image=home_img,bg=bg,bd=0,command=home_func).place(x=8,y=4)
plus_img = PhotoImage(file='resources/plus2.png')
plus_button = Button(win, image=plus_img,bd=0,command=email_func)
##Menu Bar
menu_bg = Label(win, text='',bg=bg,width=15,font=('arial black',15,'bold'),relief='groove',height=16)
log_bg = Label(win,bg=bg,width=30,height=9,relief='groove')
login_img =PhotoImage(file='resources/login.png')
log_img = Label(win,image=login_img,bg=bg)
log_in_as = Label(win, text='Logged In As : ',bg=bg,font=('',13),fg='white')
name = Label(win, text=username,bg=bg,font=('',10,'bold'),fg='white')
if len(username) > 25:
name['font'] = ('',9,'bold')
mail_img = PhotoImage(file='resources/mail.png')
mail_b = Button(win, image=mail_img, bg=bg,bd=0,text=' Compose Email',compound='left',fg='white',font=('arial black',10,'bold'),command=email_func)
mul_mail_img = PhotoImage(file='resources/mul_mail.png')
mul_mail_b = Button(win, image=mul_mail_img, bg=bg,bd=0,text=' Multiple Emails',compound='left',fg='white',font=('arial black',10,'bold'),command=mul_mail_func)
setting_img = PhotoImage(file='resources/camera-settings-icon-white-300x300.png')
setting_b = Button(win, image=setting_img, bg=bg,bd=0,text=' Settings',compound='left',fg='white',font=('arial black',10,'bold'))
about_img = PhotoImage(file='resources/about.png')
about_b = Button(win, image=about_img, bg=bg,bd=0,text=' About',compound='left',fg='white',font=('arial black',10,'bold'),command=about_func)
logout_img = PhotoImage(file='resources/logout-24.png')
logout_b = Button(win, image=logout_img, bg=bg,bd=0,text=' Log Out',compound='left',fg='white',font=('arial black',10,'bold'),command=logout_func)
cl_l = Label(win, text='Click + button\nto send email.',fg='#c8c8c8',font=('arial black',15,'bold'))
## Compose Email
header_l = Label(win, text='Compose Email',font=('Cambria',20))
to_l = Label(win, text='To : ',font=('Cambria',15))
to_e = Entry(win, font=('Cambria',15),width=30)
subject_l = Label(win, text='Subject : ',font=('Cambria',15))
subject_e = Entry(win, font=('Cambria',15),width=27)
mail_text = Text(win,wrap=WORD, font=('Cambria',13),height=10,width=43)
send_b = Button(win, text='Send',bg='green',fg='white',bd=0, font=('Cambria',13),command=vald_email)
cancel_b = Button(win, text='Cancel',bg='red',fg='white',bd=0, font=('Cambria',13),command=home_func)
csv_b = Button(win, text='Attach Email CSV file',bd=2, font=('Cambria',13),command=csv_func)
about2_img = PhotoImage(file='resources/about (2).png')
csv_ab = Button(win, image=about2_img,bd=0,command=lambda : mb.showinfo('Info','Attach a CSV file containing all the email addresses to whom you want to send the mail. Remember that the first line of the CSV file should be "email" other wise it will raise error.'))
home_func()
win.mainloop()
main_loop()