Wherever the mail is and whatever format it is stored in, the same operations to manipulate emails are common.  To unified the C API, GNU mailutils offers a heteroclite set of objects that work in aggregation to do operations on emails.  Each object do a specific task and delegates non related tasks to others.  The object comes alive by specifying a URL parameter when created, it will indicate the storage format or protocol (POP3, IMAP4, MH, MAILDIR, etc ..).

                               folder_t                  url_t
       -/var/mail-    +- .. ->+-----------------+   +-->+------------+
      (  alain *-)-+  |       |   url_t       *-|---+   |   port     |
       ----------- |  |       |-----------------|       |   hostname |
      (  jakob *-)-+--+       |   auth_t      *-|---+   |   file     |
       ----------- |          |-----------------|   |   |   ...      |
      (  jeff  *-)-+          |   stream_t      |   |   +------------+
       ----------- |          |-----------------|   |
      (  shaleh*-)-+          |   .....         |   |    auth_t
       ----------             |-----------------|   +-->+------------+
                          +---|-* mailbox_t[]   |       |   ticket_t |
       mailbox_t          |   +-----------------+       +------------+
      +----------------+<-+
      |   locker_t  *--|-------------+
      |----------------|             |
      |   url_t        |             |          locker_t
      |----------------|             +-------->+---------+
      |   stream_t     |                       | lock    |
      |----------------|                       | unlock  |
      |  message_t[] *-|-------+               +---------+
      +----------------+       |                     envelope_t
                               |          +-------->+-----------+
       message_t               |          |         | date      |
      +----------------+<------+          |         | from      |
      |   envelope_t *-|------------------+         | to        |
      |----------------|              header_t      +-----------+
      |   header_t   *-|------------>+--------------+
      |----------------|             |   stream_t   |
      |   body_t     *-|----+        +--------------+
      +----------------+    |    body_t
                            +-->+--------------+
                                |   stream_t   |
                                +--------------+

For example writing a simple from command that will list the From and Subject headers of every mail in a mailbox.

          [file sfrom.c.texi not included]

     % MAIL=pop://alain@localhost ./sfrom
     Passwd: xxxx
     Jim Meyering <meyering@foo.org>      fetish(shellutils) beta
     François Pinard <pinard@bar.org> recode new alpha
     ...

Folder
======

     [file folder.texi not included]

Mailbox
=======

     [file mailbox.texi not included]

Mailer
======

     [file mailer.texi not included]

Message
=======

     [file message.texi not included]

Envelope
========

     [file envelope.texi not included]

Headers
=======

     [file headers.texi not included]

Body
====

     [file body.texi not included]

Attribute
=========

     [file attribute.texi not included]

Stream
======

     [file stream.texi not included]

Iterator
========

     [file iterator.texi not included]

Authenticator
=============

     [file auth.texi not included]

Address
=======

     [file address.texi not included]

Locker
======

     [file locker.texi not included]

URL
===

     [file url.texi not included]