#!/usr/bin/python -tt import smtplib from email.MIMEText import MIMEText import os import sys def email_user(username, subject, text): """email extras list with the new package listing""" mail_from = 'admin@fedoraproject.org' mail_to = '%s@fedoraproject.org' % username output = text msg = MIMEText(output) msg['Subject'] = subject msg['From'] = mail_from msg['To'] = mail_to s = smtplib.SMTP() s.connect() s.sendmail(mail_from, [mail_to], msg.as_string()) s.close() if len(sys.argv) < 4: print "Usage:\n spam_fedora_user.py username subject file_of_text\n" sys.exit(1) username = sys.argv[1] subject = sys.argv[2] textfile = sys.argv[3] text = open(textfile, 'r').read() email_user(username, subject,text)