<commit_before>#
# Use this script to quickly send a bunch of mails. Useful for testing.
#
import smtplib
import datetime
import time
from email.mime.text import MIMEText

numMails = 10
address = "127.0.0.1"
smtpPort = 8000

me = "<EMAIL>"
to = "<EMAIL>"
body = """Hello,

This is a test message. It is here to test the SMTP server and
admin called MailSlurper. I sure hope it all works!!

Sincerely,
<NAME>"""

try:

	for index in range(numMails):
		msg = MIMEText(body)
		msg["Subject"] = "Test Message #{0}".format(index)
		msg["From"] = me
		msg["To"] = to
		msg["Date"] = datetime.datetime.now().strftime("%a, %d %b %Y %H:%M:%S +0000 UTC")

		server = smtplib.SMTP("{0}:{1}".format(address, smtpPort))
		server.sendmail(me, [to], msg.as_string())
		server.quit()

		time.sleep(1)


except Exception as e:
	print("An error occurred while trying to connect and send the email: {0}".format(e.message))
<commit_msg>Mail generator tool for testing now pulls quotes from iheartquotes.com. Made test mails so much better. refs #10<commit_after>#
# Use this script to quickly send a bunch of mails. Useful for testing.
#
import sys
import json
import time
import smtplib
import urllib2
import datetime

from email.mime.text import MIMEText

def getQuote():
	response = urllib2.urlopen("http://www.iheartquotes.com/api/v1/random?format=json")
	obj = json.loads(response.read())

	quoteLines = obj["quote"].split("--")

	if len(quoteLines) > 0:
		return {
			"quote": quoteLines[0].strip(),
			"source": "Unknown" if len(quoteLines) <= 1 else quoteLines[1].strip(),
		}
	else:
		return {
			"quote": "No quote",
			"source": "<NAME>"
		}

if __name__ == "__main__":
	numMails = 5
	address = "127.0.0.1"
	smtpPort = 8000

	me = "<EMAIL>"
	to = "<EMAIL>"

	try:
		for index in range(numMails):
			quote = getQuote()

			body = "<p>Hello,</p><p>Here is today's quote.</p><p><em>{0}</em><br />&nbsp;&nbsp;-- {1}</p><p>Sincerely,<br /><NAME></p>".format(quote["quote"], quote["source"],)
			msg = MIMEText(body)

			msg["Subject"] = "Quote From {0}".format(quote["source"])
			msg["From"] = me
			msg["To"] = to
			msg["Date"] = datetime.datetime.now().strftime("%a, %d %b %Y %H:%M:%S +0000 UTC")

			server = smtplib.SMTP("{0}:{1}".format(address, smtpPort))
			server.sendmail(me, [to], msg.as_string())
			server.quit()

			time.sleep(2)


	except Exception as e:
		print("An error occurred while trying to connect and send the email: {0}".format(e.message))
		print(sys.exc_info())

{'fraction_non_alphanumeric': 0.1752827140549273, 'fraction_numerical': 0.0210016155088853, 'mean_word_length': 4.171189979123174, 'pattern_counts': {'":': 5, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5786044', 'n_tokens_mistral': 991, 'n_tokens_neox': 900, 'n_words': 255}