Email processing in Python (was: e-mail processing in C)

Patrick C pcloches at
Mon Mar 24 12:04:17 PDT 2008

Searching real quick shows the existence of both libmime and libmbox...
don't know if they're maintained. Another option would be to dig out the
associated code in pine, elm, or whatnot. See how they access mail.


On 24/03/2008, Giorgos Keramidas <keramida at> wrote:
> On Mon, 24 Mar 2008 14:32:02 -0400, Robert Huff <roberthuff at>
> wrote:
> > I need to write a quick and not-too-dirty C program to process some
> > e-mail.  (Including dealing with mbox files.)
> >
> > Is there a standard library to do this?  Respectfully,
> No, there's no library for `email processing' in the C standard.  You
> can probably find a lot of non-standard ones, by Googling however :)
> It's worth writing that plain C is the wrong language for this sort of
> thing, if you ask me.  There are excellent high-level libraries in Perl,
> and Python to do this sort of thing.  Email processing is going to
> require a log of string processing, and C is notoriously 'tricky' for
> this sort of thing.
> As an example of the expressiveness of using a higher level language,
> you can display the authors of all the messages in a UNIX mailbox with
> the following short Python script:
>     import mailbox
>     m = mailbox.mbox('/home/keramida/mbox')
>     for message in m:
>         author = m['from]
>         print author
> This is not just a `readable pseudo-code-like example'.  It's *real*
> Python code, that you can run _now_ in your Python shell.
> To perform a similar task in plain C you will need several dozens of
> lines of code, and it won't necessarily be as readable.  It _may_ be
> faster, in some cases, but it will probably won't be as 'safe'.
> _______________________________________________
> freebsd-questions at mailing list
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe at"

More information about the freebsd-questions mailing list