#!/usr/bin/env python

"""
A simple utility program to send an e-mail at the end of the condor
processing.
"""
import sys
import smtplib

LABEL = sys.argv[1]
RECIPIENT = sys.argv[2]

from email.mime.text import MIMEText
BODY_INPUT_FILE = open(sys.argv[3], 'rb')
MESSAGE = MIMEText(BODY_INPUT_FILE.read())
BODY_INPUT_FILE.close()

MESSAGE['Subject'] = 'End of Condor processing: %s' % LABEL
_FROM = 'ippdor@ifa.hawaii.edu'
MESSAGE['From'] = _FROM
_TO = [ RECIPIENT, 'schastel@ifa.hawaii.edu' ]
MESSAGE['To'] = RECIPIENT
SMTP_CONNECTION = smtplib.SMTP('ippc18.ifa.hawaii.edu')
SMTP_CONNECTION.sendmail(_FROM, _TO, MESSAGE.as_string())
SMTP_CONNECTION.quit()

