You might like my email.d too https://github.com/adamdruppe/arsd/blob/master/email.d It is able to help construct emails and also read an mbox format - part of that code might help your imap library too.