import smtplib, sys, MimeWriter, StringIO, base64, os, time
def mail(serverURL=None, sender='', to='', subject='', text=''):
message = StringIO.StringIO()
writer = MimeWriter.MimeWriter(message)
writer.addheader('Subject', subject)
writer.startmultipartbody('mixed')
# start off with a text/plain part
part = writer.nextpart()
body = part.startbody('text/plain')
body.write(text)
# now add an attachment
part = writer.nextpart()
part.addheader('Content-Transfer-Encoding', 'base64')
body = part.startbody('text/plain')
base64.encode(open(filename, 'rb'), body)
# finish off
writer.lastpart()
# send the mail
smtp = smtplib.SMTP(serverURL)
smtp.
sendmail(sender, to, message.getvalue())
smtp.quit()