LEMONADE                                                      P. Resnick
Internet-Draft                                     QUALCOMM Incorporated
Expires: June 11, 2005                                 December 11, 2004


       Internet Message Access Protocol (IMAP) CATENATE Extension
                    draft-ietf-lemonade-catenate-03

Status of this Memo

   This document is an Internet-Draft and is subject to all provisions
   of section 3 of RFC 3667.  By submitting this Internet-Draft, each
   author represents that any applicable patent or other IPR claims of
   which he or she is aware have been or will be disclosed, and any of
   which he or she become aware will be disclosed, in accordance with
   RFC 3668.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF), its areas, and its working groups.  Note that
   other groups may also distribute working documents as
   Internet-Drafts.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   The list of current Internet-Drafts can be accessed at
   http://www.ietf.org/ietf/1id-abstracts.txt.

   The list of Internet-Draft Shadow Directories can be accessed at
   http://www.ietf.org/shadow.html.

   This Internet-Draft will expire on June 11, 2005.

Copyright Notice

   Copyright (C) The Internet Society (2004).

Abstract

   The CATENATE extension to the Internet Message Access Protocol (IMAP)
   allows clients to create messages on the IMAP server which may
   contain a combination of new data along with parts of (or entire)
   messages already on the server.  Using this extension, the client can
   catenate parts of an already existing message on to a new message
   without having to first download the data and then upload it back to
   the server.




Resnick                  Expires June 11, 2005                  [Page 1]


Internet-Draft          IMAP CATENATE Extension            December 2004


1.  Introduction

   The CATENATE extension to the Internet Message Access Protocol (IMAP)
   [1] allows the client to create a message on the server which can
   include the text of messages (or parts of messages) that already
   exist on the server without having to FETCH them and APPEND them back
   to the server.  The CATENATE command works much like the APPEND
   command except that, instead of a single message literal, the command
   can take as arguments any combination of message literals (as
   described in IMAP [1]) and message URLs (as described in the IMAP URL
   Scheme [2] specification).  The server takes all of the pieces and
   catenates them into the output message.

   There are some obvious uses for the CATENATE command.  The motivating
   use case for this command was to provide a way for a
   resource-constrained client to compose a message for subsequent
   submission which contains data that already exists in that client's
   IMAP store.  Because the client does not have to download and
   re-upload potentially large message parts, bandwidth and processing
   limitations do not have as much impact.  In addition, since CATENATE
   creates the message in the client's IMAP store, the command also
   addresses the desire of the client to archive a copy of a sent
   message without having to upload the message twice.  (Mechanisms for
   sending the message are outside of the scope of this document.)

   CATENATE can also be used to copy parts of a message to another
   mailbox for archival purposes while getting rid of undesired parts.
   In environments where server storage is limited, a client could get
   rid of large message parts by copying over only the necessary parts
   and then deleting the original message.  CATENATE could also be used
   to add data to a message such as prepending message header fields or
   including other data by making a copy of the original and catenating
   the new data.

2.  The CATENATE Capability

   A server which supports this extension returns "CATENATE" as one of
   the responses to the CAPABILITY command.

3.  The CATENATE command

   Arguments:     mailbox name
                  message parameter list or NIL
                  one or more message parts to catenate, specified as:
                                 message literal






Resnick                  Expires June 11, 2005                  [Page 2]


Internet-Draft          IMAP CATENATE Extension            December 2004


                                                or
                                 message (or message part) URL

   Responses: no specific responses for this command

   Result:
      OK -  catenate completed
      NO -  catenate error: can't append to that mailbox, error in flags
            or date/time or message text, or can't fetch that data
      BAD - command unknown or arguments invalid

   The CATENATE command concatenates all of the message parts and
   appends them as a new message to the end of the specified mailbox.
   The message parameters defined in this document for the message
   parameter list are a parenthesized flag list (indicated by "FLAGS")
   and date/time string (indicated by "DATE") that are used just as they
   are in the APPEND command, setting the flags and the internal date,
   respectively.  The subsequent command parameters specify the message
   parts that are appended sequentially to the output message.

   If a message literal is specified (indicated by the "TEXT"), the
   octets following the count are appended just as they would be with
   the APPEND command.  If a message URL is specified (indicated by
   "URL"), the octets of the body part pointed to by that URL are
   appended, as if the literal returned in a FETCH BODY response were
   put in place of the message part specifier.  The CATENATE command
   does not cause the \Seen flag to be set for any catenated body part.

      Note: This document only describes the behavior of the CATENATE
      command using a message URL (as defined by [2]) which refers to a
      specific message or message part in the currently selected mailbox
      on the current IMAP server.  (Because of that, the CATENATE
      command is valid in the selected state for purposes of this
      specification.) Use of a URL that refers to anything other than a
      message or message part from the currently selected mailbox on the
      current IMAP server is outside of the scope of this document,
      would require an extension to this specification, and a server
      implementing only this specification would return NO to such a
      request.

   The client is responsible for making sure that the catenated message
   is in the format of an RFC 2822 [3] message.  This includes inserting
   appropriate MIME [4] boundaries between body parts if necessary.

   Responses behave just as the APPEND command.  If the server
   implements the IMAP UIDPLUS extension [5], it will also return an
   APPENDUID response code in the tagged OK response.  Two response
   codes are provided in section 4 which can be used in the tagged NO



Resnick                  Expires June 11, 2005                  [Page 3]


Internet-Draft          IMAP CATENATE Extension            December 2004


   response if the CATENATE command fails.

4.  Response Codes

   When a CATENATE command fails it may return a response code that
   describes a reason for the failure.

4.1  BADURL Response

   The BADURL response code is returned if the CATENATE fails to process
   one of the specified URLs.  Possible reasons for this are bad url
   syntax, unrecognized URL schema, invalid message UID, invalid body
   part.  The BADURL response code contains the first URL specified as a
   parameter to the CATENATE command that has caused the operation to
   fail.

4.2  TOOBIG Response

   The TOOBIG response code is returned if the resulting message will
   exceed the 4Gb IMAP message limit.  This might happen, for example,
   if the client specifies 3 URLs for 2Gb messages.  Note, that even if
   the server doesn't return TOOBIG, it still has to be defensive
   against misbehaving or malicious clients that try to construct a
   message over 4Gb limit.  The server may also wish to return the
   TOOBIG response code if the resulting message exceeds the server
   specific message size limit.

























Resnick                  Expires June 11, 2005                  [Page 4]


Internet-Draft          IMAP CATENATE Extension            December 2004


5.  Formal Syntax

   The following syntax specification uses the Augmented Backus-Naur
   Form (ABNF) [6] notation.  Elements not defined here can be found in
   the formal syntax of the ABNF [6] and IMAP [1] specifications.  Note
   that resp-text-code is extended from original IMAP [1] specification.

   catenate = "CATENATE" SP mailbox SP parameters
                       1*(SP (text-literal / url))

   parameters = ("(" parameter *(SP parameter) ")") / "NIL"

   parameter = ("FLAGS" SP flag-list) / ("DATE" SP date-time)

   text-literal = "TEXT" SP literal

   url = "URL" SP astring

   badurl_response_code = "BADURL" SP url-text

   url-resp-text= 1*(%x01-09 / %x0B-0C / %x0E-5B / %x5D-FE)
                       ; Any TEXT-CHAR except "]"

   toobig_response_code = "TOOBIG"

   resp-text-code =/ badurl_response_code / toobig_response_code

   The astring in the definition of url and the url-text in the
   definition of badurl_response_code contain an imapurl as defined by
   [2].

6.  Acknowledgments

   Thanks to Alexey Melnikov for the Examples.  Thanks to all of the
   LEMONADE working group for their input.

7.  Security Considerations

   The CATENATE extension does not raise any security considerations
   that are not present for the base protocol or in the use of IMAP
   URLs, and these issues are discussed in the IMAP [1] and IMAP URL [2]
   documents.

8.  IANA Considerations

   IMAP4 capabilities are registered by publishing a standards track or
   IESG approved experimental RFC.  The registry is currently located at
   <http://www.iana.org/assignments/imap4-capabilities>.  This document



Resnick                  Expires June 11, 2005                  [Page 5]


Internet-Draft          IMAP CATENATE Extension            December 2004


   defines the CATENATE IMAP capability.  IANA is requested to add this
   capability to the registry.

Appendix A.  Examples

   Lines not starting with "C: " or "S: " are continuations of the
   previous lines.

   The original message in examples 1 and 2 below (UID = 20) has the
   following structure:
      multipart/mixed MIME message with two body parts:
      1.  text/plain
      2.  application/x-zip-compressed

   Example 1: The following example demonstrates how a CATENATE client
   can replace an attachment in a draft message, without the need to
   download it to the client and upload it back.

   C: A003 CATENATE Drafts FLAGS (\Seen \Draft $MDNSent)
       URL "imap://imap.example.org/Drafts;UIDVALIDITY=385759045/;
      UID=20;section=HEADER" TEXT {40}
   S: + Ready for literal data
   C: --------------030308070208000400050907
   C:  URL "imap://imap.example.org/Drafts;UIDVALIDITY=385759045/;
      UID=20;section=1.1" TEXT {40}
   S: + Ready for literal data
   C: --------------030308070208000400050907
   C:  URL "imap://imap.example.org/Drafts;UIDVALIDITY=385759045/;
      UID=30" {44}
   S: + Ready for literal data
   C: --------------030308070208000400050907--
   C:
   S: A003 OK CATENATE Completed


















Resnick                  Expires June 11, 2005                  [Page 6]


Internet-Draft          IMAP CATENATE Extension            December 2004


   Example 2: The following example demonstrates how CATENATE can be
   used to replace edited text in a draft message, as well as header
   fields for the top level message part (e.g.  Subject has changed).
   The previous version of the draft is marked as \Deleted.  Note, that
   the server also supports the UIDPLUS extension, so the APPENDUID
   response code is returned in the successful OK response to the
   CATENATE command.

   C: A003 CATENATE Drafts FLAGS (\Seen \Draft $MDNSent) TEXT {738}
   S: + Ready for literal data
   C: Return-Path: <bar@example.org>
   C: Received: from [127.0.0.2]
   C:           by rufus.example.org via TCP (internal) with ESMTPA;
   C:           Thu, 11 Nov 2004 16:57:07 +0000
   C: Message-ID: <419399E1.6000505@example.org>
   C: Date: Thu, 12 Nov 2004 16:57:05 +0000
   C: From: Bob Ar <bar@example.org>
   C: X-Accept-Language: en-us, en
   C: MIME-Version: 1.0
   C: To: foo@example.net
   C: Subject: About our holiday trip
   C: Content-Type: multipart/mixed;
   C:               boundary="------------030308070208000400050907"
   C:
   C: --------------030308070208000400050907
   C: Content-Type: text/plain; charset=us-ascii; format=flowed
   C: Content-Transfer-Encoding: 7bit
   C:
   C: Our travel agent has sent the updated schedule.
   C:
   C: Cheers,
   C: Bob
   C: --------------030308070208000400050907
   C:  URL "imap://imap.example.org/Drafts;UIDVALIDITY=385759045/;
      UID=20;Section=1.2" TEXT {44}
   S: + Ready for literal data
   C: --------------030308070208000400050907--
   C:
   S: A003 OK [APPENDUID 385759045 45] CATENATE Completed
   C: A004 UID STORE 20 +FLAGS.SILENT (\Deleted)
   S: A004 OK STORE completed










Resnick                  Expires June 11, 2005                  [Page 7]


Internet-Draft          IMAP CATENATE Extension            December 2004


   Example 3: The following example demonstrates how CATENATE can be
   used to strip attachments.  Below a PowerPoint attachment was
   replaced by a small text part explaining that the attachment was
   stripped.

   C: A003 CATENATE Drafts FLAGS (\Seen \Draft $MDNSent)
       URL "imap://imap.example.org/Drafts;UIDVALIDITY=385759045/;
      UID=21;section=HEADER" TEXT {40}
   S: + Ready for literal data
   C: --------------030308070208000400050903
   C:  URL "imap://imap.example.org/Drafts;UIDVALIDITY=385759045/;
      UID=21;section=1.1" TEXT {255}
   S: + Ready for literal data
   C: --------------030308070208000400050903
   C: Content-type: text/plain; charset="us-ascii"
   C: Content-transfer-encoding: 7bit
   C:
   C: This bodypart contained a Power Point presentation, that was
   C: deleted upon your request.
   C: --------------030308070208000400050903--
   C:
   S: A003 OK CATENATE Completed





























Resnick                  Expires June 11, 2005                  [Page 8]


Internet-Draft          IMAP CATENATE Extension            December 2004


   Example 4: The following example demonstrates a failed CATENATE
   command.  The server returns the BADURL response code to indicate
   that one of the provided URLs is invalid.  This example also
   demonstrates how CATENATE can be used to construct a digest of
   several messages.

   C: A003 CATENATE Sent FLAGS (\Seen $MDNSent) TEXT {541}
   S: + Ready for literal data
   C: Return-Path: <foo@example.org>
   C: Received: from [127.0.0.2]
   C:           by rufus.example.org via TCP (internal) with ESMTPA;
   C:           Thu, 11 Nov 2004 16:57:07 +0000
   C: Message-ID: <419399E1.6000505@example.org>
   C: Date: Thu, 21 Nov 2004 16:57:05 +0000
   C: From: Farren Oo <foo@example.org>
   C: X-Accept-Language: en-us, en
   C: MIME-Version: 1.0
   C: To: bar@example.org
   C: Subject: Digest of the mailing list for today
   C: Content-Type: multipart/digest;
   C:               boundary="------------030308070208000400050904"
   C:
   C: --------------030308070208000400050904
   C:  URL "imap://imap.example.org/INBOX;UIDVALIDITY=785799047/;
      UID=11467" TEXT {40}
   S: + Ready for literal data
   C: --------------030308070208000400050904
   C:  URL "imap://imap.example.org/INBOX;UIDVALIDITY=785799047/;
      UID=113330;section=1.5.9" TEXT {40}
   S: + Ready for literal data
   C: --------------030308070208000400050904
   C:  URL "imap://imap.example.org/INBOX;UIDVALIDITY=785799047/;
      UID=11916" TEXT {44}
   S: + Ready for literal data
   C: --------------030308070208000400050904--
   C:
   S: A003 NO [BADURL "imap://imap.example.org/INBOX;UIDVALIDITY=785799047/
      ;UID=113330;section=1.5.9"] CATENATE has failed, one message expunged


9  Normative References

   [1]  Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1",
        RFC 3501, March 2003.

   [2]  Newman, C., "IMAP URL Scheme", RFC 2192, September 1997.

   [3]  Resnick, P., "Internet Message Format", RFC 2822, April 2001.



Resnick                  Expires June 11, 2005                  [Page 9]


Internet-Draft          IMAP CATENATE Extension            December 2004


   [4]  Freed, N. and N. Borenstein, "Multipurpose Internet Mail
        Extensions (MIME) Part One: Format of Internet Message Bodies",
        RFC 2045, November 1996.

   [5]  Myers, J., "IMAP4 UIDPLUS extension", RFC 2359, June 1998.

   [6]  Crocker, D. and P. Overell, "Augmented BNF for Syntax
        Specifications: ABNF", RFC 2234, November 1997.


Author's Address

   Peter W. Resnick
   QUALCOMM Incorporated
   5775 Morehouse Drive
   San Diego, CA  92121-1714
   US

   Phone: +1 858 651 4478
   EMail: presnick@qualcomm.com
   URI:   http://www.qualcomm.com/~presnick/






























Resnick                  Expires June 11, 2005                 [Page 10]


Internet-Draft          IMAP CATENATE Extension            December 2004


Intellectual Property Statement

   The IETF takes no position regarding the validity or scope of any
   Intellectual Property Rights or other rights that might be claimed to
   pertain to the implementation or use of the technology described in
   this document or the extent to which any license under such rights
   might or might not be available; nor does it represent that it has
   made any independent effort to identify any such rights.  Information
   on the procedures with respect to rights in RFC documents can be
   found in BCP 78 and BCP 79.

   Copies of IPR disclosures made to the IETF Secretariat and any
   assurances of licenses to be made available, or the result of an
   attempt made to obtain a general license or permission for the use of
   such proprietary rights by implementers or users of this
   specification can be obtained from the IETF on-line IPR repository at
   http://www.ietf.org/ipr.

   The IETF invites any interested party to bring to its attention any
   copyrights, patents or patent applications, or other proprietary
   rights that may cover technology that may be required to implement
   this standard.  Please address the information to the IETF at
   ietf-ipr@ietf.org.


Disclaimer of Validity

   This document and the information contained herein are provided on an
   "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
   OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
   ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
   INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.


Copyright Statement

   Copyright (C) The Internet Society (2004).  This document is subject
   to the rights, licenses and restrictions contained in BCP 78, and
   except as set forth therein, the authors retain all their rights.


Acknowledgment

   Funding for the RFC Editor function is currently provided by the
   Internet Society.




Resnick                  Expires June 11, 2005                 [Page 11]