#!/usr/bin/python

import sys
from smtplib import SMTP
from email.mime.text import MIMEText
server = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
sender = sys.argv[4]
recipientStr = sys.argv[5]
recipients = recipientStr.split()
subject = sys.argv[6]
body = sys.argv[7]
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = recipientStr
try:
	s = SMTP()
	s.connect(server)
	s.login(username, password)
	s.sendmail(sender, recipients, msg.as_string())
except Exception as e:
	sys.stderr.write(str(e))
	sys.exit(1)
