· 9 years ago · Nov 10, 2016, 12:24 AM
1#!/usr/bin/python
2
3from Tkinter import *
4import smtplib
5
6def SendMail():
7 domain = '@gmail.com'
8 try:
9
10 server=smtplib.SMTP_SSL('smtp.gmail.com',465)
11 server.ehlo()
12 server.login(gmuser.get()+domain,gmpass.get())
13 server.sendmail(gmuser.get()+domain,sendto.get(),'Subject: %s\n\n%s' % (subject.get(),message.get()))
14 server.close()
15 print 'Sent OK'
16 except:
17 print 'error'
18
19mGUI=Tk()
20mGUI.title('Send GMail by noxon@RT')
21
22gmuser = Entry(mGUI,justify=RIGHT)
23gmpass = Entry(mGUI)
24sendto = Entry(mGUI,justify=RIGHT)
25subject = Entry(mGUI)
26message = Entry(mGUI)
27
28Label(mGUI, text="To\t:").grid(row=0)
29Label(mGUI, text="Subject\t:").grid(row=1)
30Label(mGUI, text="Message\t:").grid(row=2,sticky=W+N)
31Label(mGUI, text='Gmail User ').grid(row=8)
32Label(mGUI, text='Gmail Pass ').grid(row=9)
33Label(mGUI, text='@Gmail.com').grid(row=8,column=2)
34
35sendto.grid(row=0, column=1,sticky=W)
36subject.grid(row=1, column=1,sticky=W)
37message.grid(row=2, column=1,sticky=W+S,ipady=20,rowspan=6,pady=4)
38gmuser.grid(row=8, column=1,sticky=W)
39gmpass.grid(row=9, column=1,sticky=W)
40
41Button(mGUI, text='Quit', command=mGUI.quit).grid(row=10, column=0, sticky=W, pady=4)
42Button(mGUI, text='Send', command=SendMail).grid(row=10, column=3, sticky=W, pady=4)
43
44mainloop()