A cross-platform .NET library for IMAP, POP3, and SMTP.
A cross-platform .NET library for IMAP, POP3, and SMTP.
| Package | Latest Release | Latest Build |
|---|---|---|
| MimeKit | ||
| MimeKitLite | ||
| MailKit | ||
| MailKitLite |
| Platform | Build Status | Code Coverage | Static Analysis |
|---|---|---|---|
| Linux/Mac | |||
| Windows |
MailKit is a cross-platform mail client library built on top of MimeKit.
MailKit is a personal open source project that I have put thousands of hours into perfecting with the goal of making it the very best email framework for .NET. I need your help to achieve this.
Donating helps pay for things such as web hosting, domain registration and licenses for developer tools such as a performance profiler, memory profiler, a static code analysis tool, and more. It also helps motivate me to continue working on the project.
USER/PASS.The main goal of this project is to provide the .NET world with robust, fully featured and RFC-compliant SMTP, POP3, and IMAP client implementations.
All of the other .NET IMAP client implementations that I could find suffer from major architectural
problems such as ignoring unexpected untagged responses, assuming that literal string tokens will
never be used for anything other than message bodies (when in fact they could be used for pretty
much any string token in a response), assuming that the way to find the end of a message body in a
FETCH response is by scanning for ") UID", and not properly handling mailbox names with international
characters to simply name a few.
IMAP requires a LOT of time spent laboriously reading and re-reading the IMAP specifications (as well as the MIME specifications) to understand all of the subtleties of the protocol and most (all?) of the other Open Source .NET IMAP libraries, at least, were written by developers that only cared enough that it worked for their simple needs. There's nothing necessarily wrong with doing that, but the web is full of half-working, non-RFC-compliant IMAP implementations out there that it was finally time for a carefully designed and implemented IMAP client library to be written.
For POP3, libraries such as OpenPOP.NET are actually fairly decent, although the MIME parser is far too strict - throwing exceptions any time it encounters a Content-Type or Content-Disposition parameter that it doesn't already know about, which, if you read over the mailing-list, is a problem that OpenPOP.NET users are constantly running into. MailKit's Pop3Client, of course, doesn't have this problem. It also parses messages directly from the socket instead of downloading the message into a large string buffer before parsing it, so you'll probably find that not only is MailKit faster (MailKit's MIME parser, MimeKit, parses messages from disk 25x faster than OpenPOP.NET's parser), but also uses far less memory.
For SMTP, most developers use System.Net.Mail.SmtpClient which suits their needs more-or-less satisfactorily and so is probably not high on their list of needs. However, the SmtpClient implementation included with MailKit is a much better option if cross-platform support is needed or if the developer wants to be able to save and re-load MIME messages before sending them via SMTP. MailKit's SmtpClient also supports PIPELINING which should improve performance of sending messages (although might not be very noticeable).
…The easiest way to install MailKit is via NuGet.
In Visual Studio's Package Manager Console, enter the following command:
Install-Package MailKitFirst, you'll need to clone MailKit from my GitHub repository. To do this using the command-line version of Git, you'll need to issue the following command in your terminal:
git clone --recursive https://github.com/jstedfast/MailKit.gitIf you are using TortoiseGit on Windows, you'll need to right-click in the directory where you'd like to clone MailKit and select Git Clone... in the menu. Once you do that, you'll get the following dialog:
Fill in the areas outlined in red and then click OK. This will recursively clone MailKit onto your local machine.
Occasionally you might want to update your local copy of the source code if I have made changes to MailKit since you downloaded the source code in the step above. To do this using the command-line version of Git, you'll need to issue the following commands in your terminal within the MailKit directory:
git pull
git submodule updateIf you are using TortoiseGit on Windows, you'll need to right-click on the MailKit directory and select Git Sync... in the menu. Once you do that, you'll need to click the Pull and Submodule Update buttons in the following dialog:
In the top-level MailKit directory, there are a number of solution files; they are:
Once you've opened the appropriate MailKit solution file in Visual Studio, you can choose the Debug or Release build configuration and then build.
Both Visual Studio 2017 and Visual Studio 2019 should be able to build MailKit without any issues, but older versions such as Visual Studio 2015 will require modifications to the projects in order to build correctly. It has been reported that adding NuGet package references to Microsoft.Net.Compilers >= 3.6.0 and System.ValueTuple >= 4.5.0 to the MimeKit and MailKit projects will allow them to build successfully.
Note: The Release build will generate the xml API document
Implement the IMAP Extension for Returning Mailbox METADATA in Extended LIST
Code Sign release artifacts
Server issue compatibility: MailKit 4.16.0 connect imap.sohu.com:993 has exception for CAPABILITIES
Make `IMailFolder.GetMessage()` return `IMimeMessage`
Add support for JMAP
SmtpClient Exception Behavior Change in 4.4.0
Implement the IMAP Response Code for Command Progress Notifications