<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"/> <title>Reading message contents</title> <link rel="stylesheet" href="manpage.css" type="text/css"/> <link rel="start" href="index.html" title="Cone: COnsole Newsreader And Emailer"/> <link rel="up" href="smap1.html" title="Appendix A. Simple Mail Access Protocol, Version 1"/> <link rel="prev" href="attributes.html" title="Reading message attributes"/> <link rel="next" href="store.html" title="Modifying message attributes"/> <link xmlns="" rel="icon" href="icon.gif" type="image/gif"/> <meta xmlns="" name="MSSmartTagsPreventParsing" content="TRUE"/> <!-- Copyright 2002 - 2007 Double Precision, Inc. See COPYING for distribution information. --> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center" rowspan="1">Reading message contents</th> </tr> <tr> <td width="20%" align="left" rowspan="1" colspan="1"> <a accesskey="p" href="attributes.html" shape="rect">Prev</a> </td> <th width="60%" align="center" rowspan="1" colspan="1"> Appendix A. Simple Mail Access Protocol, Version 1</th> <td width="20%" align="right" rowspan="1" colspan="1">  <a accesskey="n" href="store.html" shape="rect">Next</a></td> </tr> </table> <hr/> </div> <div class="section" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="smapmessagecontents" shape="rect" name="smapmessagecontents"> </a>Reading message contents</h3> </div> </div> </div> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 CONTENTS=BODY<br clear="none"/> S: {.7160} FETCH 1 CONTENTS<br clear="none"/> S:<br clear="none"/> S: Hello,<br clear="none"/> S:<br clear="none"/> S: There will be a meeting tomorrow.<br clear="none"/> S:<br clear="none"/> S:<span class="emphasis"><em>...</em></span><br clear="none"/> S:<br clear="none"/> S: .<br clear="none"/> S: * FETCH 1 FLAGS=<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> <p>There are additional <code class="literal">FETCH</code> keywords that instruct the server to retrieve the actual message contents. These keywords, described in the following sections, may be requested at the same time as the attribute keywords specified in the previous section. The server will respond with both single-line replies that contain the attributes, and multi-line replies that contain the requested message content. As always, the server may send the individual replies in any order.</p> <p>The <code class="literal">CONTENTS=</code><em class="replaceable"><code>part</code></em> keyword results in a <a class="link" href="smapsyntax.html#singleline" title="Single line replies" shape="rect">multiple line</a> reply from the server, returning the requested content, specified by <em class="replaceable"><code>part</code></em>. The server may use either multiple line format (dot-stuffed, or binary) at its discretion. The server may use either the <code class="literal">LF</code> or the <code class="literal">CRLF</code> sequence to terminate lines. The server automatically sets the <code class="literal">SEEN</code> flag on this message, which SHOULD generate an additional single line <code class="literal">* FETCH</code> reply from the server.</p> <p>Using <code class="literal">CONTENTS.PEEK</code> instead of <code class="literal">CONTENTS</code> does not set the <code class="literal">SEEN</code> flag. The following documentation refers only to <code class="literal">CONTENTS</code>, but either one may be used; they are identical to each other in all ways except for the <code class="literal">SEEN</code> flag.</p> <p><em class="replaceable"><code>part</code></em> should be a keyword chosen from the following list:</p> <div class="variablelist"> <dl> <dt><span class="term"><code class="literal">HEADERS(</code><em class="replaceable"><code>list</code></em><code class="literal">)</code></span></dt> <dd> <p>Returns only the header portion of the message. <em class="replaceable"><code>list</code></em> is a comma-separated list of case-insensitive header names. The list may be empty, in which case all the headers are returned; otherwise only the specified headers are returned, if they are present. <em class="replaceable"><code>list</code></em> may also contain the following keywords which are a shorthand representation for frequently requested headers:</p> <div class="variablelist"> <dl> <dt><span class="term"><code class="literal">:ENVELOPE</code></span></dt> <dd> <p>This is the same as “<span class="quote">DATE,SUBJECT,FROM,SENDER,REPLY-TO,TO,CC,BCC,IN-REPLY-TO,MESSAGE-ID,REFERENCES</span>”.</p> </dd> <dt><span class="term"><code class="literal">:MIME</code></span></dt> <dd> <p>This is the same as “<span class="quote">:ENVELOPE</span>”, plus “<span class="quote">MIME-VERSION</span>” and all headers that start with “<span class="quote">CONTENT-</span>”.</p> </dd> </dl> </div> <p>In all cases, folded header lines are automatically unfolded by the server. All folding newline characters, and the leading whitespace on the continuation lines, are replaced by a single space character. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 CONTENTS.PEEK=HEADERS(FROM,MIME-VERSION,CONTENT-TYPE)<br clear="none"/> S: {.300} FETCH 1 HEADERS<br clear="none"/> S: Mime-Version: 1.0<br clear="none"/> S: Content-Type: text/plain; charset=iso-8859-1<br clear="none"/> S: From: Tom Jones <tjones@example.com><br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> <p>Another example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 CONTENTS.PEEK=HEADERS(:ENVELOPE)<br clear="none"/> S: {.300} FETCH 1 HEADERS<br clear="none"/> S: From: Tom Jones <tjones@example.com><br clear="none"/> S: To: Bob Smith <bsmith@example.com><br clear="none"/> S: Subject: Meeting<br clear="none"/> S: Message-ID: <802374jekdj90@example.com><br clear="none"/> S: Date: Mon, 21 Apr 2002 16:56:11 -0400<br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> </dd> <dt><span class="term"><code class="literal">MIME(</code><em class="replaceable"><code>list</code></em><code class="literal">)</code></span></dt> <dd> <p>Returns the header portion of all MIME sections in the message. <em class="replaceable"><code>list</code></em> is a comma-separated list of case-insensitive header names, as in the <code class="literal">HEADER</code> keyword. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 CONTENTS.PEEK=MIME(MIME-VERSION,CONTENT-TYPE,CONTENT-TRANSFER-ENCODING)<br clear="none"/> S: {.80} FETCH 1 LINES=207 SIZE=3120 MIME.ID=<br clear="none"/> S: Mime-Version: 1.0<br clear="none"/> S: Content-Type: multipart/mixed; boundary="0123456789ABCDEF"<br clear="none"/> S: .<br clear="none"/> S: {.40} FETCH 1 LINES=185 SIZE=1012 MIME.ID=1 MIME.PARENT=<br clear="none"/> S: Content-Type: multipart/alternative; boundary="ABCDEF0123456789"<br clear="none"/> S: .<br clear="none"/> S: {.80} FETCH 1 LINES=81 SIZE=208 "MIME.ID=1 1" MIME.PARENT=1<br clear="none"/> S: Content-Type: text/plain; charset=iso-8859-1<br clear="none"/> S: Content-Transfer-Encoding: quoted-printable<br clear="none"/> S: .<br clear="none"/> S: {.80} FETCH 1 LINES=42 SIZE=783 "MIME.ID=1 2" MIME.PARENT=1<br clear="none"/> S: Content-Type: text/html; charset=iso-8859-1<br clear="none"/> S: Content-Transfer-Encoding: quoted-printable<br clear="none"/> S: .<br clear="none"/> S: {.80} FETCH 1 LINES=50 SIZE=1257 MIME.ID=2 MIME.PARENT=<br clear="none"/> S: Content-Type: image/gif<br clear="none"/> S: Content-Transfer-Encoding: base64<br clear="none"/> S: .<br clear="none"/> S: {.80} FETCH 1 LINES=45 SIZE=907 MIME.ID=3 MIME.PARENT=<br clear="none"/> S: Content-Type: message/rfc822<br clear="none"/> S: .<br clear="none"/> S: {.120} FETCH 1 LINES=27 SIZE=452 "MIME.ID=3 1" MIME.PARENT=3<br clear="none"/> S: Mime-Version: 1.0<br clear="none"/> S: Content-Type: text/plain; charset=iso-8859-1<br clear="none"/> S: Content-Transfer-Encoding: 8bit<br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> <p><a class="ulink" href="http://www.rfc-editor.org/rfc/rfc2045.txt" target="_top" shape="rect">RFC 2045</a>, and related documents, specifies the format of MIME messages. A MIME message contains one or more individual or multipart MIME sections; a multipart MIME section itself contains inferior individual or multipart sections, forming a distinct hierarchy. Consult RFCs 2045 through 2049 for additional information.</p> <p><code class="literal">MIME(</code><em class="replaceable"><code>list</code></em><code class="literal">)</code> parses the MIME structure of a message, and recursively returns the requested headers from each MIME section in the message. The server returns a series of <a class="link" href="smapsyntax.html#multiline" title="Multiple line replies" shape="rect">multi-line</a> replies, each reply carries headers from a single MIME section. The multi-line replies may be sent in any order, except that the headers for the topmost MIME section must always be sent first, and the headers from the other MIME sections may only be sent after the headers from their parent MIME section, and the headers from all of their preceding sibling MIME section (which is just a fancy way of saying that the server uses either the prefix or the infix traversal order).</p> <p>The server assigns a unique “<span class="quote">MIME section ID</span>” to each MIME section. The method the server uses to generate a MIME section ID is entirely up to the server, with one exception: the MIME section ID for the entire message must be an empty string. SMAP clients should treat MIME section ID as opaque text strings, and must not interpret them in any way (except for the blank mime ID referring to the entire message).</p> <p>“<span class="quote"><code class="literal">MIME.ID=</code><em class="replaceable"><code>id</code></em></span>” specifies the MIME section ID of the following headers. “<span class="quote"><code class="literal">MIME.PARENT=</code><em class="replaceable"><code>id</code></em></span>” specifies the MIME section ID of the parent MIME section (this attribute is not specified for the topmost MIME section, which has no parent). “<span class="quote"><code class="literal">MIME.PARENT=</code><em class="replaceable"><code>id</code></em></span>” is not returned for the first, topmost MIME section, and since its MIME section ID is always an empty string, its inferior MIME section will have “<span class="quote"><code class="literal">MIME.PARENT=</code></span>”, the empty <em class="replaceable"><code>id</code></em> referring to the topmost MIME section.</p> <p>The SMAP client uses this information to reconstruct the structure of the MIME message.</p> <p>The above example shows a MIME <code class="literal">multipart/mixed</code> message with three sections. The first section is a MIME <code class="literal">multipart/alternative</code> with two subsections: <code class="literal">text/plain</code> and <code class="literal">text/html</code>. The second section is an <code class="literal">image/gif</code>, and the third section is a <code class="literal">message/rfc822</code>.</p> <p><code class="literal">message/rfc822</code> MIME sections are parsed as multipart sections, with exactly one component section: the attached message. The above example shows that the attached message consists of a single <code class="literal">text/plain</code> section.</p> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> <h3 class="title">Note</h3> <p>The <code class="literal">MIME.ID</code>, <code class="literal">MIME.PARENT</code>, <code class="literal">SIZE</code> and <code class="literal">LINES</code> values may occur in any order. <code class="literal">SIZE</code> gives an estimated size of the content portion of the MIME section, and <code class="literal">LINES</code> gives the approximate number of text lines in the content portion of the MIME section. These numbers are not to be taken as exact counts, but as ballpark estimates.</p> </div> </dd> <dt><span class="term"><code class="literal">HEADERS[</code><em class="replaceable"><code>id</code></em><code class="literal">](</code><em class="replaceable"><code>list</code></em><code class="literal">)</code></span></dt> <dd> <p>This is the same as <code class="literal">HEADERS(</code><em class="replaceable"><code>list</code></em><code class="literal">)</code>, except that the server returns headers from the MIME section specified by <em class="replaceable"><code>id</code></em>. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 "CONTENTS.PEEK=HEADERS[1 2](CONTENT-TYPE,CONTENT-TRANSFER-ENCODING)"<br clear="none"/> S: {.80} FETCH 1 HEADERS<br clear="none"/> S: Content-Type: text/html; charset=iso-8859-1<br clear="none"/> S: Content-Transfer-Encoding: quoted-printable<br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> </dd> <dt><span class="term"><code class="literal">BODY</code></span></dt> <dd> <p>Returns the only the body portion of the message. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 CONTENTS=BODY<br clear="none"/> S: {.80} FETCH 1 BODY<br clear="none"/> S: Mary had a little lamb, its fleece was white as snow,<br clear="none"/> S: and everywhere Mary went, the lamb was sure to go.<br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> </dd> <dt><span class="term"><code class="literal">BODY[</code><em class="replaceable"><code>id</code></em><code class="literal">]</code></span></dt> <dd> <p>Returns the only the body portion of the specified MIME section. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 "CONTENTS=BODY[1 1]"<br clear="none"/> S: {.80} FETCH 1 BODY<br clear="none"/> S: Itsy-bitsy spider went up the water spout,<br clear="none"/> S: Down came the rain, and washed the spider out.<br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> </dd> <dt><span class="term"><code class="literal">ALL</code></span></dt> <dd> <p>Returns both the headers and the body portion of the message.</p> </dd> <dt><span class="term"><code class="literal">ALL[</code><em class="replaceable"><code>id</code></em><code class="literal">]</code></span></dt> <dd> <p>Returns the headers, a blank line, then the body portion of the specified MIME section. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 "CONTENTS=ALL[1 1]"<br clear="none"/> S: {.120} FETCH 1 ALL<br clear="none"/> S: Content-Type: text/plain; charset=iso-8859-1<br clear="none"/> S: Content-Transfer-Encoding: 7bit<br clear="none"/> S:<br clear="none"/> S: Itsy-bitsy spider went up the water spout,<br clear="none"/> S: Down came the rain, and washed the spider out.<br clear="none"/> S: .<br clear="none"/> S: +OK Ok<br clear="none"/></p> </div> <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> <h3 class="title">Note</h3> <p>Unlike <code class="literal">HEADERS</code>, folded header lines are not unfolded by <code class="literal">ALL</code>.</p> </div> </dd> <dt><span class="term"><code class="literal">BODY.DECODED</code></span></dt> <dd> <p>Same as <code class="literal">BODY</code> except that the server automatically decodes the MIME-encoded section, and sends the raw decoded content as a binary, multi-line reply. Example:</p> <div class="literallayout"> <p><br clear="none"/> C: FETCH 1 CONTENTS=BODY.DECODED<br clear="none"/> S: {322/322} FETCH 1 BODY.DECODED<br clear="none"/> S:<br clear="none"/> S: <span class="emphasis"><em>[ 322 bytes, then a blank line, follows ]</em></span><br clear="none"/> S: +OK Ok.<br clear="none"/></p> </div> </dd> <dt><span class="term"><code class="literal">BODY.DECODED[</code><em class="replaceable"><code>id</code></em><code class="literal">]</code></span></dt> <dd> <p>Return the decoded contents of the indicated MIME section.</p> </dd> </dl> </div> </div> <div class="navfooter"> <hr/> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left" rowspan="1" colspan="1"> <a accesskey="p" href="attributes.html" shape="rect">Prev</a> </td> <td width="20%" align="center" rowspan="1" colspan="1"> <a accesskey="u" href="smap1.html" shape="rect">Up</a></td> <td width="40%" align="right" rowspan="1" colspan="1">  <a accesskey="n" href="store.html" shape="rect">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top" rowspan="1" colspan="1">Reading message attributes </td> <td width="20%" align="center" rowspan="1" colspan="1"> <a accesskey="h" href="index.html" shape="rect">Home</a> | <a accesskey="t" href="bk01-toc.html" shape="rect">ToC</a></td> <td width="40%" align="right" valign="top" rowspan="1" colspan="1"> Modifying message attributes</td> </tr> </table> </div> </body> </html>