-
Notifications
You must be signed in to change notification settings - Fork 2
/
SendEmail.py
84 lines (61 loc) · 2.72 KB
/
SendEmail.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
import smtplib
import tkinter
from tkinter import font
class sendParkingTicket(object):
def __init__(self, str):
self.str = str
self.receiverEmail = None
def windowForEmail(self):
self.messageWindow = tkinter.Tk()
self.messageWindow.title("Parking Lot")
self.messageWindow.geometry("200x100-200-400")
self.messageWindow.config(bg="#FA8072")
self.messageWindow['pady'] = 5
label = tkinter.Label(self.messageWindow, text='Enter your Email address', bg='#FA8072')
label['font'] = tkinter.font.Font(size=20, family='Helvetica', weight='bold')
label.pack()
self.mailAddress = tkinter.Entry(self.messageWindow, width=25)
self.mailAddress.pack()
sendButton = tkinter.Button(self.messageWindow, text='Send', bg='#FF7F50', activebackground='#FFA500',
command=self.send_Email)
sendButton.pack(side='bottom', anchor='s')
self.messageWindow.minsize(250, 100)
self.messageWindow.maxsize(250, 100)
self.messageWindow.mainloop()
def send_Email(self):
self.receiverEmail = self.mailAddress.get()
try:
ob = smtplib.SMTP('imap.gmail.com', 587)
ob.starttls()
ob.login("MailID@gmail.com", "passward")
subject = "PARKING TICKET"
body = self.str
message = 'Subject : {}\n\n{}'.format(subject, body)
ob.sendmail("ParkingLotSystem12@gmail.com", self.receiverEmail, message)
# print("send successful..")
ob.quit()
self.messageWindow.destroy()
self.window = tkinter.Tk()
self.window.title("Parking Lot")
self.window.geometry("200x70-200-400")
self.window.config(bg="#FA8072")
self.window['pady'] = 20
label = tkinter.Label(self.window, text='Email Sent Successfully!', bg="#FA8072")
label.pack()
self.window.minsize(200, 70)
self.window.maxsize(200, 70)
self.window.after(2500, self.window.destroy)
self.window.mainloop()
except smtplib.SMTPRecipientsRefused as e:
self.messageWindow.destroy()
self.warning = tkinter.Tk()
self.warning.title("Parking Lot")
self.warning.geometry("200x70-250-400")
self.warning.config(bg="#FA8072")
self.warning["pady"] = 15
label = tkinter.Label(self.warning, text="Please enter correct Email!", bg="#FA8072")
label.pack()
self.warning.minsize(200, 70)
self.warning.maxsize(200, 70)
self.warning.after(2500, self.warning.destroy)
self.warning.mainloop()