Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

MailKit

> 开发工具
Open source

A cross-platform .NET library for IMAP, POP3, and SMTP.

6.8K stars0 likes1 views
WebsiteGitHub

About

A cross-platform .NET library for IMAP, POP3, and SMTP.

MailKit

Package Latest Release Latest Build
MimeKit
MimeKitLite
MailKit
MailKitLite
Platform Build Status Code Coverage Static Analysis
Linux/Mac
Windows

What is MailKit?

MailKit is a cross-platform mail client library built on top of MimeKit.

Donate

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.

Features

  • SASL Authentication
    • Supports the following mechanisms: CRAM-MD5, DIGEST-MD5, LOGIN, NTLM, PLAIN, SCRAM-SHA-1[-PLUS], SCRAM-SHA-256[-PLUS], SCRAM-SHA-512[-PLUS], OAUTHBEARER and XOAUTH2
  • Proxy Support
    • Supports the following types of proxies: SOCKS4/4a, SOCKS5, and HTTP/S
  • SMTP Client
    • Supports all of the SASL mechanisms listed above.
    • Supports SSL-wrapped connections via the "smtps" protocol.
    • Supports client SSL/TLS certificates.
    • Supports the following extensions: SIZE, DSN, AUTH, 8BITMIME, PIPELINING, BINARYMIME, CHUNKING, STARTTLS, and SMTPUTF8
    • All APIs are cancellable.
    • Async APIs are available.
  • POP3 Client
    • Supports all of the SASL mechanisms listed above.
    • Also supports authentication via APOP and USER/PASS.
    • Supports SSL-wrapped connections via the "pops" protocol.
    • Supports client SSL/TLS certificates.
    • Supports the following extensions: TOP, UIDL, EXPIRE, LOGIN-DELAY, PIPELINING, SASL, STLS, UTF8, UTF8=USER, and LANG
    • All APIs are cancellable.
    • Async APIs are available.
  • IMAP4 Client
    • Supports all of the SASL mechanisms listed above.
    • Supports SSL-wrapped connections via the "imaps" protocol.
    • Supports client SSL/TLS certificates.
    • Supports the following extensions: ACL, QUOTA, LITERAL+, IDLE, NAMESPACE, ID, CHILDREN, LOGINDISABLED, STARTTLS, MULTIAPPEND, UNSELECT, UIDPLUS, CONDSTORE, ESEARCH, SASL-IR, COMPRESS, WITHIN, ENABLE, QRESYNC, SORT, THREAD, ANNOTATE, LIST-EXTENDED, ESORT, METADATA / METADATA-SERVER, NOTIFY, FILTERS, LIST-STATUS, SORT=DISPLAY, SPECIAL-USE / CREATE-SPECIAL-USE, SEARCH=FUZZY, MOVE, UTF8=ACCEPT / UTF8=ONLY, LITERAL-, APPENDLIMIT, STATUS=SIZE, OBJECTID, REPLACE, SAVEDATE, PARTIAL, XLIST, and X-GM-EXT1 (X-GM-MSGID, X-GM-THRID, X-GM-RAW and X-GM-LABELS)
    • All APIs are cancellable.
    • Async APIs are available.
  • Client-side sorting and threading of messages.

Goals

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).

License Information

…

Installing via NuGet

The easiest way to install MailKit is via NuGet.

In Visual Studio's Package Manager Console, enter the following command:

Install-Package MailKit

Getting the Source Code

First, 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:

bash
git clone --recursive https://github.com/jstedfast/MailKit.git

If 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.

Updating the Source Code

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:

bash
git pull
git submodule update

If 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:

Building

In the top-level MailKit directory, there are a number of solution files; they are:

  • MailKit.sln - includes the projects for .NET Framework 4.6.2/4.7/4.8, .NETStandard 2.0/2.1, .NET6.0 as well as the unit tests.
  • MailKit.Coverity.sln - this is used to generate Coverity static analysis builds and is not generally useful.
  • MailKit.Documentation.sln - this is used to generate the documentation found at https://mimekit.net/docs

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

Issues· 10 open

View all issuesOpen on GitHub
  • #1835

    Implement the IMAP Extension for Returning Mailbox METADATA in Extended LIST

    enhancementUpdated Sep 23, 2026
  • #1882

    Code Sign release artifacts

    enhancementUpdated Jul 27, 2026
  • #2006

    Server issue compatibility: MailKit 4.16.0 connect imap.sohu.com:993 has exception for CAPABILITIES

    server-bugUpdated Jul 14, 2026
  • #1933

    Make `IMailFolder.GetMessage()` return `IMimeMessage`

    enhancementUpdated Dec 7, 2025
  • #1552

    Add support for JMAP

    enhancementUpdated Oct 29, 2025
  • #1748

    SmtpClient Exception Behavior Change in 4.4.0

    enhancementUpdated Mar 23, 2025
  • #1837

    Implement the IMAP Response Code for Command Progress Notifications

    enhancementUpdated Nov 4, 2024

> Tags

C#c-sharpdkimemailimap

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具