{"id":32958228,"url":"https://github.com/danzuep/MailKitSimplified","last_synced_at":"2025-11-16T17:02:00.370Z","repository":{"id":61075613,"uuid":"541205019","full_name":"danzuep/MailKitSimplified","owner":"danzuep","description":"Send and receive emails easily, fluently, with one line of code for each operation.","archived":false,"fork":false,"pushed_at":"2025-11-01T07:34:13.000Z","size":1028,"stargazers_count":92,"open_issues_count":2,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-11-01T09:16:17.539Z","etag":null,"topics":["asynchronous","csharp","dependency-injection","devops-enabled","email","email-reader","email-receiver","email-sender","fluent","imap","imap-client","mail","mailer","smtp","smtp-client","unit-tested"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danzuep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"danzuep","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-09-25T14:50:16.000Z","updated_at":"2025-11-01T07:34:18.000Z","dependencies_parsed_at":"2023-11-29T03:38:02.870Z","dependency_job_id":"707f423c-b546-4ffb-9ef5-fb27864ddd1d","html_url":"https://github.com/danzuep/MailKitSimplified","commit_stats":{"total_commits":176,"total_committers":1,"mean_commits":176.0,"dds":0.0,"last_synced_commit":"3a61f9112f27a59e6bd2ece03deec5ccb90bd218"},"previous_names":[],"tags_count":108,"template":false,"template_full_name":null,"purl":"pkg:github/danzuep/MailKitSimplified","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danzuep%2FMailKitSimplified","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danzuep%2FMailKitSimplified/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danzuep%2FMailKitSimplified/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danzuep%2FMailKitSimplified/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danzuep","download_url":"https://codeload.github.com/danzuep/MailKitSimplified/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danzuep%2FMailKitSimplified/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284742551,"owners_count":27056072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","csharp","dependency-injection","devops-enabled","email","email-reader","email-receiver","email-sender","fluent","imap","imap-client","mail","mailer","smtp","smtp-client","unit-tested"],"created_at":"2025-11-12T23:00:34.015Z","updated_at":"2025-11-16T17:02:00.364Z","avatar_url":"https://github.com/danzuep.png","language":"C#","funding_links":["https://github.com/sponsors/danzuep"],"categories":["Mail","Parsing"],"sub_categories":["GUI - other"],"readme":"# MailKitSimplified [![Code Size](https://img.shields.io/github/languages/code-size/danzuep/MailKitSimplified)](https://github.com/danzuep/MailKitSimplified)\n\nSending and receiving emails sounds simple, after all, electronic mail existed [decades](https://en.wikipedia.org/wiki/History_of_email) before the [Internet](https://en.wikipedia.org/wiki/History_of_the_Internet). If you're looking for an all-in-one .NET solution for email, you'll quickly discover [MailKit](https://github.com/jstedfast/MailKit) is recommended by even the likes of [Microsoft](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=net-6.0#remarks) due to how it implements the [RFC standard](https://www.rfc-editor.org/rfc/rfc2822). Unfortunately the downside of doing it all is that MailKit can be difficult to [set up](https://github.com/jstedfast/MailKit#using-mailkit) [and use](https://github.com/jstedfast/MimeKit/blob/master/FAQ.md#messages-1), especially the first time you go to try something like [working with attachments](https://github.com/jstedfast/MimeKit/blob/master/FAQ.md#q-how-do-i-tell-if-a-message-has-attachments) or [writing a reply](https://github.com/jstedfast/MimeKit/blob/master/FAQ.md#q-how-do-i-reply-to-a-message). The aim of this package is to make sending and receiving emails as simple as possible!\n\n## SMTP with MailKitSimplified.Sender [![NuGet](https://img.shields.io/nuget/v/MailKitSimplified.Sender.svg)](https://nuget.org/packages/MailKitSimplified.Sender) [![Downloads](https://img.shields.io/nuget/dt/MailKitSimplified.Sender.svg?style=flat-square)](https://www.nuget.org/packages/MailKitSimplified.Sender)\n\nSending an email with MailKitSimplified.Sender is as easy as:\n\n```csharp\nusing var smtpSender = SmtpSender.Create(\"localhost\");\nawait smtpSender.WriteEmail.To(\"test@localhost\").SendAsync();\n```\n\n## IMAP with MailKitSimplified.Receiver [![NuGet](https://img.shields.io/nuget/v/MailKitSimplified.Receiver.svg)](https://nuget.org/packages/MailKitSimplified.Receiver) [![Downloads](https://img.shields.io/nuget/dt/MailKitSimplified.Receiver.svg?style=flat-square)](https://www.nuget.org/packages/MailKitSimplified.Receiver)\n\nReceiving emails with MailKitSimplified.Receiver is as easy as:\n\n```csharp\nusing var imapReceiver = ImapReceiver.Create(\"localhost\");\nvar mimeMessages = await imapReceiver.ReadMail.Top(1).GetMimeMessagesAsync();\n```\n\nYou can even monitor an email folder for new messages asynchronously, never before has it been this easy!\n\n```csharp\nawait imapReceiver.MonitorFolder.OnMessageArrival(m =\u003e Console.WriteLine(m.UniqueId)).IdleAsync();\n```\n\nOnce you've got either a mime message or a message summary, replying is now equally as intuitive.\n\n```csharp\nvar mimeReply = mimeMessage.GetReplyMessage(\"\u003cp\u003eReply here.\u003c/p\u003e\").From(\"noreply@example.com\");\n```\n\nYou're welcome. 🥲\n\n## Example Usage [![Development](https://github.com/danzuep/MailKitSimplified/actions/workflows/development.yml/badge.svg)](https://github.com/danzuep/MailKitSimplified/actions/workflows/development.yml) [![Release](https://github.com/danzuep/MailKitSimplified/actions/workflows/release.yml/badge.svg)](https://github.com/danzuep/MailKitSimplified/actions/workflows/release.yml)\n\nThe examples above will actually work with no other setup if you use something like [smtp4dev](https://github.com/rnwood/smtp4dev) (e.g. `docker run -d -p 3000:80 -p 25:25 -p 143:143 rnwood/smtp4dev`), but below are some more realistic examples. The cancellation token is recommended but not required.\n\n### Sending Mail\n\n```csharp\nusing var smtpSender = SmtpSender.Create(\"smtp.example.com:587\")\n    .SetCredential(\"user@example.com\", \"App1icati0nP455w0rd\")\n    .SetProtocolLog(\"Logs/SmtpClient.txt\");\nawait smtpSender.WriteEmail\n    .From(\"my.name@example.com\")\n    .To(\"YourName@example.com\")\n    .Bcc(\"admin@example.com\")\n    .Subject(\"Hello World\")\n    .BodyHtml(\"\u003cp\u003eHi\u003c/p\u003e\")\n    .Attach(\"appsettings.json\")\n    .TryAttach(@\"Logs\\ImapClient.txt\")\n    .SendAsync(cancellationToken);\n```\n\nSee the [MailKitSimplified.Sender wiki](https://github.com/danzuep/MailKitSimplified/wiki/Sender) for more information.\n\n### Receiving Mail\n\n```csharp\nusing var imapReceiver = ImapReceiver.Create(\"imap.example.com:993\")\n    .SetCredential(\"user@example.com\", \"App1icati0nP455w0rd\")\n    .SetProtocolLog(\"Logs/ImapClient.txt\")\n    .SetFolder(\"INBOX\");\nvar mimeMessages = await imapReceiver.ReadMail.Top(10)\n    .GetMimeMessagesAsync(cancellationToken);\n```\n\nTo only download the [message parts](http://www.mimekit.net/docs/html/T_MailKit_MessageSummaryItems.htm) you want to use:\n\n```csharp\nvar reader = imapReceiver.ReadMail\n    .Skip(0).Take(250, continuous: true)\n    .Items(MessageSummaryItems.Envelope);\nvar messageSummaries = await reader.GetMessageSummariesAsync(cancellationToken);\n```\n\nNote: MailKit returns results in ascending order by default, use messageSummaries.Reverse() to get descending results or imapReceiver.ReadMail.Top(#) to get the newest results.\n\nTo [query](http://www.mimekit.net/docs/html/T_MailKit_Search_SearchQuery.htm) unread emails from the IMAP server:\n\n```csharp\nvar messageSummaries = await imapReceiver.ReadFrom(\"INBOX/Subfolder\")\n    .Query(SearchQuery.NotSeen)\n    .ItemsForMimeMessages()\n    .GetMessageSummariesAsync(cancellationToken);\n```\n\nTo asynchronously monitor the mail folder for incoming messages:\n\n```csharp\nawait imapReceiver.MonitorFolder\n    .SetMessageSummaryItems()\n    .SetIgnoreExistingMailOnConnect()\n    .OnMessageArrival(OnArrivalAsync)\n    .IdleAsync(cancellationToken);\n```\n\nTo asynchronously forward or reply to message summaries as they arrive:\n\n```csharp\nasync Task OnArrivalAsync(IMessageSummary messageSummary)\n{\n    var mimeForward = await messageSummary.GetForwardMessageAsync(\n        \"\u003cp\u003eFYI.\u003c/p\u003e\", includeMessageId: true);\n    mimeForward.From.Add(\"from@example.com\");\n    mimeForward.To.Add(\"to@example.com\");\n    //logger.LogInformation($\"Reply: \\r\\n{mimeForward.HtmlBody}\");\n    //await smtpSender.SendAsync(mimeForward, cancellationToken);\n}\n```\n\nSee the [MailKitSimplified.Receiver wiki](https://github.com/danzuep/MailKitSimplified/wiki/Receiver) for more information.\n\n## See Also [![License](https://img.shields.io/github/license/danzuep/MailKitSimplified)](https://github.com/danzuep/MailKitSimplified)\n\nExamples of things like dependency injection, a hosted service, or an ASP.NET API can also be found in the [GitHub samples](https://github.com/danzuep/MailKitSimplified/tree/main/samples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanzuep%2FMailKitSimplified","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanzuep%2FMailKitSimplified","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanzuep%2FMailKitSimplified/lists"}