import sys
from xml.xslt.Processor import Processor


def OutMime():
    processor = Processor()
    processor.appendStylesheetUri('mime.xsl')
    result = processor.runUri('message.xml')
    print '*** Result ***'
    print result


    msg = """Content-Type: multipart/text/html;
    boundary="127.0.0.1.500.12859.945235597.150.29161"
From: Mike Olson


--127.0.0.1.500.12859.945235597.150.29161
Content-Type: text/html

Body
--127.0.0.1.500.12859.945235597.150.29161
Content-Type: text/html

Sub body
"""

    import smtplib
    SMTP_SERVER='localhost'
    EMAIL_FROM='Jove@localhost'
    server = smtplib.SMTP(SMTP_SERVER)
    server.set_debuglevel(1)
    try:
        address = sys.argv[1]
    except:
        address = 'bitbucket@dev.null'
    server.sendmail(EMAIL_FROM, [address], result)
    server.quit()


if __name__ == '__main__':
    OutMime()

