'Add the given message to the given mailbox.
This command is allowed in the Authenticated and Selected states.
@type mailbox: L{str}
@param mailbox: The mailbox to which to add this message.
@type message: Any file-like object
@param message: The message to add, in RFC822 format.  Newlines
in this file should be \r\n-style.
@type flags: Any iterable of L{str}
@param flags: The flags to associated with this message.
@type date: L{str}
@param date: The date to associate with this message.  This should
be of the format DD-MM-YYYY HH:MM:SS +/-HHMM.  For example, in
Eastern Standard Time, on July 1st 2004 at half past 1 PM,
"01-07-2004 13:30:00 -0500".
@rtype: C{Deferred}
@return: A deferred whose callback is invoked when this command
succeeds or whose errback is invoked if it fails.'

def append(self, mailbox, message, flags=(), date=None):

    message.seek(0, 2)
    L = message.tell()
    message.seek(0, 0)
    fmt = '%s    (%s)%s    {%d}'
    if date:
        date = ('    "%s"' % date)
    else:
        date = ''
    cmd = (fmt % (_prepareMailboxName(mailbox), '    '.join(flags), date, L))
    d = self.sendCommand(Command('APPEND', cmd, (), self.__cbContinueAppend, message))
    return d
