Free Software
Commercial Software
About me


  Intro   Download   Features   Documentation   Mailing lists   Code Snippets  

mimetic is a free, MIT licensed, Email library (MIME) written in C++ designed to be easy to use and integrate but yet fast and efficient.

I'm a fan of the C++ Standard Library so mimetic has been built around the standard lib. This means that you'll not find yet another string class or list implementation and that you'll feel comfortable in using this library from the very first time.

mimetic doesn't use exceptions but it heavily uses templates so a mostly standard compliant C++ compiler is required. I developed it using GCC 3.x and tested on most Unixes. When it comes to performance the stdlib is important (and GCC's is not the fastest library around) so mimetic code include some classes that are not strictly needed but are there just to improve performance (for ex. the File class for memory mapped file access).

Most classes functionalities and behavior will be clear if you ever studied MIME and its components; if you don't know anything about Internet messages you'll probably want to read some RFCs to understand the topic and, therefore, easily use the library whose names, whenever possible, overlap terms adopted in the standard RFC documents. At the very least: RFC 822, RFC 2045 and RFC 2046. A more complete list can be found at the Earl Wood's MIME page.

Being a programmers I know that a code snippet is better then thousand words :), so if you want you can jump to the Code Snippets section.


Latest release is 0.9.8

You can download it here: mimetic-0.9.8.tar.gz


  • Very easy to use
    This was, from the beginning, one of the objectives of mimetic.
    If you know the MIME standard you'll rarely need online documentation.
  • Full featured
    Everything you expect to find in a MIME library is already into mimetic, if you'll not find it is because your requirements are probably insane :) Oh well cryptography is not in the library yet, but it will some day.
  • Standard compliant
    mimetic tries to follow current standards as closely as possible.
  • STL based
    This could be a very big advantage if you know the STL and want to integrate mimetic into your STL based project. You'll have same powerful concepts and classes fully applicable to emails. If you don't know the STL so this is a good opportunity to learn it! A very good reference (yet freely readable) is the Dinkum C++ Library Reference.
  • Compile-time codec chains
    Codec chains are template based so that codecs are chained together by the compiler using inline functions whenever possible to speed up runtime performance.
    Creating a codec chain will sound very familiar if you know Unix pipes:
    codec0 | codec1 | codec2 | ... | last_codec
    Jump to a more complete example
  • Portable
    I've personally tested it on Linux, {Open,Free,Net}BSD, Solaris, Mac OS X. It uses Autotools to compile so porting on any Unix system should be easy.

    Windows port has been done by Andreas Gruen but it's no loger maintained. You can get last release of Visual Studio project files into mimetic/win32 directory.

    If those are not enough please consider using Unix-style compiling on Windows using Cygwin or MinGW.

  • More then 50 test functions, more then 2500 checks
    cutee has been used for Unit Testing and there are a lot of tests the run automatically every time someone compiles mimetic. This doesn't mean that it's bug free but it helps.
  • Open source
    Source code of the library, tests and examples are bundled into the distribution package. All except codec code (that is heavily template based) is very readable so if Documentation is not good enough for you sources can be your primary reference.
  • HTML documentation
    Library documentation is generated from source code by Doxygen. You can browse it online of generate yourself for offline browsing (see Documentation section).


You can read mimetic work-in-progress documentation online here.

The same HTML documentation can be auto-generated with Doxygen:

# tar zxvf mimetic-x.y.z.tar.gz
# cd mimetic-x.y.z/doc
# make docs

Mailing lists

mimetic-users mailing list is hosted by sourceforge: mimetic-users

Code Snippets

 * Build and print a test message
#include <iostream>
#include <mimetic/mimetic.h>

using namespace std;
using namespace mimetic;

int main()
	MimeEntity me;
	me.header().from("me <me@domain.com>");
	me.header().to("you <you@domain.com>");
	me.header().subject("my first mimetic msg");
	me.body().assign("hello there!");
	cout << me << endl;
	return 0;

 * Parse and load a MIME message read from standard input and print 
 * its structure
#include <iostream>
#include <mimetic/mimetic.h>

using namespace std;
using namespace mimetic;

void printMimeStructure(MimeEntity* pMe, int tabcount = 0)
	Header& h = pMe->header();                   // get header object
	for(int c = tabcount; c > 0; --c)            // indent nested entities
		cout << "    ";                      //
	cout << h.contentType() << endl;             // prints Content-Type
	MimeEntityList& parts = pMe->body().parts(); // list of sub entities obj
	// cycle on sub entities list and print info of every item
	MimeEntityList::iterator mbit = parts.begin(), meit = parts.end();
	for(; mbit != meit; ++mbit)
		printMimeStructure(*mbit, 1 + tabcount);

int main()
	ios_base::sync_with_stdio(false);        // optimization
	istreambuf_iterator<char> bit(cin), eit; // get stdin iterators
	MimeEntity me(bit,eit);                       // parse and load message
	printMimeStructure(&me);                      // print msg structure
	return 0;

 * encode the 'source' character array and write the result to 'dest'.
 * the codec chain converts in the input to upper case, then the result to
 * Base64 and then insert a newline every 40 chars

#include <iostream>
#include <stdio.h>
#include <mimetic/mimetic.h>

using namespace std;
using namespace mimetic;

int main()
	Base64::Encoder b64(0);                  // encodes in Base64
	MaxLineLen mll(40);                      // inserts a newline every 40 chars
	ToUpperCase tup;                         // convert text to upper case
	enum { sz = 2048 };
	char source[sz], dest[2*sz];
	// fill 'source' here 
	encode(source, source + sz, tup | b64 | mll, dest);  // encode
	return 0;
Web codesink.org

Sponsored links:

All contents Copyright (c) 2003-2013 by Stefano Barbato. All Rights Reserved. Site made with vim. Syntax highlighter source-highlight