Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 from Products.SecureMailHost.SecureMailHost import SecureMailHost as Base
00002 
00003 class MockMailHost(Base):
00004     """A MailHost that collects messages instead of sending them.
00005 
00006     Thanks to Rocky Burt for inspiration.
00007     """
00008     
00009     def __init__(self, id):
00010         Base.__init__(self, id, smtp_notls=True)
00011         self.reset()
00012     
00013     def reset(self):
00014         self.messages = []
00015 
00016     def send(self, message, mto=None, mfrom=None, subject=None, encode=None):
00017         self.messages.append(message)
00018 
00019     def secureSend(self, message, mto, mfrom, **kwargs):
00020         kwargs['debug'] = True
00021         result = Base.secureSend(self, message=message, mto=mto, mfrom=mfrom, **kwargs)
00022         self.messages.append(result)
00023 
00024     def validateSingleEmailAddress(self, address):
00025         return True # why not