'Place the message in the I{new/} directory, add it to the mailbox and
fire the deferred to indicate that the task has completed
successfully.'

def moveFileToNew(self):

    while True:
        newname = os.path.join(self.mbox.path, 'new', _generateMaildirName())
        try:
            self.osrename(self.tmpname, newname)
            break
        except OSError as e:
            (err, estr) = e.args
            import errno
            if (err != errno.EEXIST):
                self.fail()
                newname = None
                break
    if (newname is not None):
        self.mbox.list.append(newname)
        self.defer.callback(None)
        self.defer = None
