#!/usr/bin/env python
#
# Run the Postman MTA client

import sys
from postman.mta import MTAClient

def usage():
    print """
    Usage: postman-mta address < raw_email_data

    address is a valid mailing list address

    raw_email_data is the raw data (txt) that contains the information of
    the email to be sent
    """
    return True

if __name__ == '__main__':
    if len(sys.argv) < 2:
        usage()
        raise SystemExit
    try:
        raw_email = sys.stdin.read()
    except:
        usage()
        raise SystemExit
    mta_client = MTAClient(address=sys.argv[1])
    mta_client.get_raw_email(raw_email)
    mta_client.run()

