I compiled with py2exe and added the setup.py script because a few people have been having trouble with email.MEME.Text working with py2exe.
The .PNG's are attached below save them to your c:/python26/
there isn't much security (passwords are temp stored in a .dat file)
________________________________________________
to: john@email.com sendcount = 100
your message will be delivered 100 times(would execute 100 times so be careful)
(message body)
________________________________________________
import Tkinter as tk
from Tkinter import*
import Image
import PngImagePlugin
import ImageTk
from PIL import Image, ImageTk
from PIL import PngImagePlugin
import os
import os.path
import os, os.path
import webbrowser
import pickle
import email
import email.mime.text
import email.mime.base
import email.mime.multipart
import email.iterators
import email.generator
import email.utils
from email.utils import COMMASPACE, formatdate
from email.MIMEText import MIMEText
import smtplib
import imaplib
class Vendetta:
def __init__(self,parent):
#image files .png format#
image1 = Image.open('button1.png')
photo1 = ImageTk.PhotoImage(image1)
image2 = Image.open('button2.png')
photo2 = ImageTk.PhotoImage(image2)
image4 = Image.open('background1.png')
photo4 = ImageTk.PhotoImage(image4)
image6 = Image.open('explosion.png')
photo6 = ImageTk.PhotoImage(image6)
image9 = Image.open('helpme.png')
photo9 = ImageTk.PhotoImage(image9)
image11 = Image.open('signup.png')
photo11 = ImageTk.PhotoImage(image11)
#main frame#
frame = Frame(parent)
frame.pack()
#main canvas#
self.canvas = Canvas(frame, width=500,height=500,bg='white')
self.canvas.pack(expand=YES, fill=BOTH)
#creates canvas background#
self.canvasbackground = Label(self.canvas,bg='white',image=photo4)
self.canvasbackground.pack(fill='both',expand='yes')
self.canvasbackground.image = photo4
#username#
self.entrybox1 = Entry(self.canvas,width = '40')
self.entrybox1.pack()
self.entrybox1.place(x=200, y=200)
self.entrybox1.bind("<Return>")
#username label#
self.label1 = Label(self.canvas,bg='white',text='Username:')
self.label1.place(x=135,y=200)
#password#
self.entrybox2 = Entry(self.canvas,show='*',width = '40')
self.entrybox2.pack()
self.entrybox2.place(x=200, y=240)
self.entrybox2.bind("<Return>")
#password label#
self.label2 = Label(self.canvas,bg='white',text='Password:')
self.label2.place(x=135,y=240)
#sign in button#
self.button1 = Button(self.canvas,image = photo1,bd=0,command=self.user_check)
self.button1.pack()
self.button1.place(x=200, y=300)
self.button1.image = photo1
#cancel button#
self.button2 = Button(self.canvas,bd=0,image = photo2)
self.button2.pack()
self.button2.place(x=300,y=300)
self.button2.image = photo2
#signup button#
self.button5 = Button(self.canvas,bg='white',bd=-5,image = photo11,command=self.sign_up)
self.button5.pack()
self.button5.place(x=395,y=355)
self.button5.image = photo11
#signup button label#
self.label3 = Label(self.canvas,bg='white',text="Don't have a google mail account?")
self.label3.place(x=200,y=355)
#help button#
# self.button4 = Button(self.canvas,bg='white',bd=-1,image = photo9)
# self.button4.pack()
# self.button4.place(x=469,y=475)
# self.button4.image = photo9
#disclaimer button#
# self.button3 = Button(self.canvas,bg='white',bd=-1,image = photo8)
# self.button3.pack()
# self.button3.place(x=410,y=475)
# self.button3.image = photo8
#opens url#
def sign_up(self):
webbrowser.open_new_tab('''https://www.google.com/accounts/NewAccount?service=mail&
continue=http://mail.google.com/mail/e-11-2b4f8983ab8114bc367
371a832107d-51ca749fd1a3b87518eeffad9d3268bf580b4523&type=2''')
def user_check(self):
update = 0;
image3 = Image.open('sendit.png')
photo3 = ImageTk.PhotoImage(image3)
image5 = Image.open('background2.png')
photo5 = ImageTk.PhotoImage(image5)
image12 = Image.open('messagewaiting.png')
photo12 = ImageTk.PhotoImage(image12)
image13 = Image.open('toaddr.png')
photo13 = ImageTk.PhotoImage(image13)
###INSERT###
userimput1 = self.entrybox1.get()
userid = str(userimput1)
pickleFile = open("googleid.dat","w")
pickle.dump(userid,pickleFile)
pickleFile.close()
userimput2 = self.entrybox2.get()
userpw = str(userimput2)
pickleFile = open("googlepw.dat","w")
pickle.dump(userpw,pickleFile)
pickleFile.close()
fo = open("googleid.dat")
username = pickle.load(fo);
fo = open("googlepw.dat")
password = pickle.load(fo);
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
print "password accepted"
self.dialogbox = Toplevel(bg='white')
self.dialogbox.resizable(width=0,height=0)
self.main_menu = Menu(self.dialogbox)
self.dialogbox.config(menu=self.main_menu)
fileMenu = Menu(self.main_menu)
self.main_menu.add_cascade( label="Credits", menu=fileMenu)
fileMenu.add_command( label="Brett McLennon")
toolMenu = Menu(self.main_menu)
# self.main_menu.add_cascade( label="Help", menu=toolMenu)
toolMenu.add_command( label="Disclaimer")
toolMenu.add_command( label="More information")
timerMenu = Menu(self.main_menu)
self.main_menu.add_cascade(label = "Timer",menu=timerMenu)
timerMenu.add_command( label="1 hour")
##Canvas 1##
self.canvas1 = Canvas(self.dialogbox,width = 600, height=400, relief=SUNKEN)
self.canvas1.pack(expand=YES, fill=BOTH)
self.canvasbackground1 = Label(self.canvas1,image=photo5)
self.canvasbackground1.pack(fill='both',expand='yes')
self.canvasbackground1.image = photo5
##googlemail inbox check##
updatelabel9 = StringVar()
dos = imaplib.IMAP4_SSL('imap.gmail.com','993')
dos.login(username,password)
self.label9 = Label(self.dialogbox,bg='white',textvariable = updatelabel9)
self.label9.place(x=450,y=380)
updatelabel9.set('connection established')
dos.select()
dos.search(None,'UnSeen')
updatelabel9.set('')
smart = len(dos.search(None,'UnSeen')[1][0].split())
##if a message exists show message waiting icon##
if (smart >= 1):
self.newmail = Button(self.dialogbox,bg='white',relief=FLAT,image =photo12)
self.newmail.place(x=450,y=370)
self.newmail.image = photo12
##terminology correction##
if (smart >= 2):
updatelabel9.set('inbox: ( %s ) new messages' % smart)
elif (smart == 1):
updatelabel9.set('inbox: ( %s ) new message' % smart)
else:
updatelabel9.set('inbox: ( %s ) no new mail.' % smart)
##Message Sent Window(*not in use*)##
#self.textbox = Text(self.dialogbox,relief=FLAT,height = 1,width=30)
#self.textbox.pack()
#self.textbox.place(x=125,y=370)
##Message Count Box##
self.entryboxi = Entry(self.dialogbox,relief=GROOVE,width=16)
self.entryboxi.pack()
self.entryboxi.place(x=500,y=95)
##Email Address Box##
self.entrybox0 = Entry(self.dialogbox,relief=GROOVE,bg='white',width=60)
self.entrybox0.pack()
self.entrybox0.place(x=124.2,y=95)
## To: Label##
self.label4 = Label(self.dialogbox,bd=0,image=photo13)
self.label4.pack()
self.label4.image = photo13
self.label4.place(x=50,y=95)
##Message Body Window##
self.textbox1 = Text(self.dialogbox,bg='white',height = 15,width=68)
self.textbox1.pack()
self.textbox1.place(x=50,y=120)
##send button##
self.sendbutton = Button(self.dialogbox,image=photo3,bd=0,command=self.send_button)
self.sendbutton.pack()
self.sendbutton.place(x=50,y=370)
self.sendbutton.image = photo3
def send_button(self):
sendcount = self.entryboxi.get()
try:
sc = int(sendcount)
except ValueError:
sc = 1;
##clears entryboxi to avoid complications##
self.entryboxi.delete(0,END)
##writes the email's messagebody to a .txt file for later use(for example)##
sendmessage = self.textbox1.get(1.0,END)
sentmsg = str(sendmessage)
fo = open("googlemail.txt","w")
fo.write(sentmsg)
fo.close()
##writes the recipents email address to a .dat file for later use##
# emailid = self.entrybox0.get()
# sendto = str(emailid)
emailbox = list('')
emailid = self.entrybox0.get()
emailbox.append(emailid)
print emailid
emailTo = open("toaddr.dat","w")
pickle.dump(emailid,emailTo)
emailTo.close()
##sets up a while loop. While the sc(sendcount) provided above is greater than-##
##0 the following block will continue to execute##
while (sc > 0):
listopen = open("googleid.dat")
username = pickle.load(listopen)
print listopen
listopen.close()
passopen = open("googlepw.dat")
password = pickle.load(passopen)
print passopen
passopen.close()
addrbook = open("toaddr.dat")
toaddr = pickle.load(addrbook)
print addrbook
addrbook.close()
msgopen = open("googlemail.txt")
msg = msgopen.read()
print msgopen
msgopen.close()
##While the loop continues, connect to the SMTP server##
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(username, toaddr, msg)
server.quit
self.textbox1.delete(1.0,END)
##subtracts 1 from the value provided by sc(sendcount)#
sc = sc - 1
print "Message delivered !!!!"
print "message #%s" % sc
#imports required modules#
# from usercheck import*
if SyntaxError:
print "safegaurd"
#plate#
root = Tk()
root.title(' ')
root.geometry('498x498')
root.resizable(0,0)
root.iconbitmap(default='transparent.ico')
end = Vendetta(root)
mainloop()
_________________________________________________________________
- Setup.py -
from distutils.core import setup
import py2exe
setup(windows=['gmail.py'],
data_files=['button1.png','button2.png','background1.png',
'background2.png','explosion.png','helpme.png',
'signup.png','sendit.png','messagewaiting.png',
'toaddr.png','information.png','transparent.ico'],
options = {
"py2exe" : {
"includes" : "email.mime.text,email.encoders,email.generator, email.iterators, email.utils, email.mime.base, email.mime.multipart,email.base64mime, "
}
})
Written by Brett McLennon
for education purposes.