def test_submit_fails(self): """this tests the __init__ function of the Connection object to ensure it fails if no message is passed.""" conn = Connection() self.assertRaises(PmtaConnectionError, conn.submit)
from port25.submitter.recipient import Recipient, PmtaRecipientError from port25.submitter.connection import Connection, PmtaConnectionError from port25 import PmtaError try: list = ('*****@*****.**', '*****@*****.**',) list_data = {'*****@*****.**': {'name': 'Peter'}, '*****@*****.**': {'name': 'Rich'},} data = "From: [email protected]\12To:[*to]\12Subject: Your Order has been processed\12Mime-Version: 1.0\12Content-type: multipart/alternative;boundary=\"PMTAMimeBoundry\"\12[name]<br><br>Hey your order of a [order] has come in. Please stop by and give us your money.<br><br>Tech Team <br>" msg = Message('*****@*****.**') rcpt = None for item in list: rcpt = Recipient(item) rcpt.defineVariable('name', list_data[item]['name']) rcpt.defineVariable('order', 'pizzas') rcpt.defineVariable('*parts', '1') msg.addRecipient(rcpt) msg.addMergeData(data) conn = Connection() conn.submit(msg) except PmtaError, e: print e except Exception, e: print "Some other error" print e.args