Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internet Protocols Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

8.1 Introduction

The MIME package represents Multipurpose Internet Mail Extensions (MIME) messages as C++ objects. The package provides a simple, convenient interface for creating and processing MIME messages.

The MIME message format allows arbitrary content to be transmitted over protocols designed to accept only 7-bit US-ASCII messages. The MIME format:

Although MIME was originally designed for use with mail applications, other protocols use the MIME format to structure nontextual or multipart message content.

MIME is specified in five RFCs, numbers 2045-2049. The MIME package also supports the multipart/related content type defined in RFC 2387, the -Content-Disposition header defined in RFC 1806, and the Content-Location header defined in RFC 2557 described on the IETF website at http://www.ietf.org.

8.1.1 Classes in the MIME Package

This package includes the following classes:

RWMimeContentDescriptionHeader

RWMimeContentDisposition

RWMimeContentDispositionHeader

RWMimeContentIdHeader

RWMimeContentLocationHeader

RWMimeContentTransferEncodingHeader

RWMimeContentType

RWMimeContentTypeHeader

RWMimeError

RWMimeGenericHeader

RWMimeHeader

RWMimeMultipart

RWMimeMultipartRelatedType

RWMimeMultipartType

RWMimeParameter

RWMimeParameterList

RWMimeParseError

RWMimePart

RWMimeTextType

RWMimeUtils

RWMimeVersionHeader

These classes are described in detail in the SourcePro C++ API Reference Guide.

8.1.2 Header Files

The rw/mime directory contains a header file for each class. The header file names have the form classname.h. For example, the header file for RWMimePart is RWMimePart.h.

You can also use the umbrella header file, mime.h, which includes the header files for all classes in the MIME package.

8.1.3 Relationship to Transport Protocols

The MIME specification defines a message format rather than a transport protocol. The format is designed to allow a message in the MIME format to be transported over existing Internet protocols, in particular SMTP.

However, simply following the MIME specification does not guarantee compatibility with older applications. For example, older SMTP servers may not correctly handle a message with data lines longer than 78 characters, even though the MIME specification itself allows data lines of up to 998 characters.

When constructing a MIME part, keep in mind the limitations of the network protocol over which the part will be transmitted. This guide provides advice for creating parts that work within the limitations of SMTP, and points out places where an application can take advantage of less restrictive protocols.

8.1.4 Approach to Validating Messages

One of the guiding principles of the Internet is to "be conservative in what you send and be liberal in what you accept." By this principle, the MIME package should make a strong effort to enforce correctness whenever the package produces a message. In contrast, one of the guiding principles of a useful class library is not to enforce policy, but instead to allow the programmer as much control as possible over the output of the program. By this principle, the MIME package should never enforce the validity of a message.

The MIME package balances these approaches. The package considers validity whenever an object sends or accepts data – in the asString(), fromString(), and setBody() member functions. The fromString() functions accept any string that the function is able to parse, regardless of whether the string contains valid MIME. However, if the function cannot extract data from the string (for example, if the string is empty), the function throws RWMimeParseError. Likewise, the setBody() functions accept any body string that the function can parse.

The asString() functions create data for a program to send, so these functions are more conservative. An asString() function throws RWMimeError if the function is unable to produce a structurally correct string. Of course, a structurally correct string can still be nonsensical – the message could claim to contain text, but actually contain a compressed image. The MIME package guarantees correct structure, but lets the programmer determine the content.

For example, the Content-ID header is required to contain both a label and a value. Given a string like "Content-ID: ", which has a label but no value, a fromString() function interprets the string as a Content-ID header with an empty value, even though such a header is invalid. However, an asString() function will not produce a Content-ID header with an empty value since there are no circumstances under which the header would be valid MIME.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.