'Handle end of message by writing the message to the file.
@rtype: L{Deferred <defer.Deferred>} which successfully results in
L{bytes}
@return: A deferred which succeeds with the name of the file to which
the message has been stored or fails if the message cannot be
saved to the file.'

def eomReceived(self):

    self.fp.seek(0, 0)
    try:
        f = open(self.finalname, 'a')
    except:
        return defer.fail(failure.Failure())
    with f:
        f.write(self.fp.read())
        self.fp.close()
    return defer.succeed(self.finalname)
