Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 from Products.MailHost.MailHost import MailHost as MailBase
00002 
00003 class MockMailHost(MailBase):
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         MailBase.__init__(self, id)
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         """
00018         Basically construct an email.Message from the given params to make sure
00019         everything is ok and store the results in the messages instance var.
00020         """
00021         self.messages.append(message)
00022 
00023     def validateSingleEmailAddress(self, address):
00024         return True # why not