--- /dev/null
+from Globals import InitializeClass, DTMLFile
+from Products.MailHost import MailHost
+from AccessControl import ClassSecurityInfo
+from AccessControl.Permissions import view_management_screens, change_configuration
+import string, re
+
+bad_path_chars_in=re.compile('[^a-zA-Z0-9-_~\,\. \/]').search
+
+
+
+manage_addFakeMailHostForm=DTMLFile('www/addFakeMailHost_form', globals())
+def manage_addFakeMailHost(dispatcher, id, title='', folderPath='', REQUEST=None) :
+ ' Add Fake mail Host'
+ parent = dispatcher.Destination()
+ fmh = FakeMailHost(id, folderPath, title='title' )
+ parent._setObject(id, fmh)
+ if REQUEST is not None:
+ REQUEST['RESPONSE'].redirect(parent.absolute_url()+'/manage_main')
+
+
+class FakeMailHost(MailHost.MailHost) :
+ """ Fake Mail Host """
+
+ meta_type = 'Fake Mail Host'
+ manage_main = DTMLFile('www/manageFakeMailHost', globals())
+ manage_main._setName('manage_main')
+ smtp_host = ''
+
+ security = ClassSecurityInfo()
+
+ def __init__(self, id, folderPath, title='', ) :
+ self.id = id
+ self.title = title
+ self.setContainerPath(path=folderPath)
+
+
+ def _send(self, mfrom, mto, messageText, immediate=False) :
+ """ Create a document based on message inside base folder """
+ folder = self._getMailContainer()
+ id = str(len(folder._objects))
+ folder.manage_addProduct['OFSP'].manage_addFile(id, file='')
+ file = getattr(folder, id)
+ file.update_data(messageText, 'text/plain')
+
+ security.declareProtected(change_configuration, 'manage_makeChanges' )
+ def manage_makeChanges(self,title,folderPath, REQUEST=None):
+ 'make the changes'
+
+ title=str(title)
+ self.title=title
+ self.setContainerPath(folderPath)
+
+ if REQUEST is not None:
+ msg = 'Fake Mail Host %s updated' % self.id
+ return self.manage_main( self
+ , REQUEST
+ , manage_tabs_message=msg
+ )
+
+ security.declareProtected(view_management_screens, 'getFolderPath')
+ def getFolderPath(self) :
+ return '/'.join(self._folderPath)
+
+
+ def _getMailContainer(self) :
+ return self.unrestrictedTraverse(self._folderPath)
+
+ security.declarePrivate('setContainerPath')
+ def setContainerPath(self, path=None):
+ if not path:
+ self._folderPath = []
+ elif type(path) is type(''):
+ if bad_path_chars_in(path):
+ raise ValueError, (
+ 'Path contains invalid characters in a Zope '
+ 'object path'
+ )
+ self._folderPath = string.split(path, '/')
+ elif type(path) in (type([]), type(())):
+ self._folderPath = list(path) # sequence
+ else:
+ raise ValueError, ('Bad path value %s' % path)
+
+InitializeClass(FakeMailHost)
\ No newline at end of file
--- /dev/null
+<dtml-var manage_page_header>
+<dtml-var "manage_form_title(this(), _, form_title='Add Fake MailHost')">
+
+<p class="form-help">
+Fake MailHost object provide a way to create File objects based on mails
+instead of sending them.
+</p>
+
+<form action="manage_addFakeMailHost" method="post">
+<table cellspacing="0" cellpadding="2" border="0">
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-label">Id</div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="id" size="40" value="MailHost" />
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-optional">Title</div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="title" size="40" />
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-label">Base folder path</div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="folderPath" size="40" value="" />
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ </td>
+ <td align="left" valign="top">
+ <div class="form-element">
+ <input class="form-element" type="submit" name="submit" value=" Add " />
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+
+<dtml-var manage_page_footer>
+
--- /dev/null
+<dtml-var manage_page_header>
+<dtml-var manage_tabs>
+
+<form action="manage_makeChanges" method="post">
+<table cellspacing="0" cellpadding="2" border="0">
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-label">
+ Id
+ </div>
+ </td>
+ <td align="left" valign="top">
+ <div class="form-text">&dtml-id;</div>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-optional">Title</div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="title" size="40" value="&dtml-title;"/>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ <div class="form-label">Base folder path</div>
+ </td>
+ <td align="left" valign="top">
+ <input type="text" name="folderPath" size="40" value="&dtml-getFolderPath;" />
+ </td>
+ </tr>
+ <tr>
+ <td align="left" valign="top">
+ </td>
+ <td align="left" valign="top">
+ <div class="form-element">
+ <input class="form-element" type="submit" name="submit"
+ value="Save Changes" />
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+
+<dtml-var manage_page_footer>