RecursiveAI.OneMail.Client
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package RecursiveAI.OneMail.Client --version 1.0.0
NuGet\Install-Package RecursiveAI.OneMail.Client -Version 1.0.0
<PackageReference Include="RecursiveAI.OneMail.Client" Version="1.0.0" />
<PackageVersion Include="RecursiveAI.OneMail.Client" Version="1.0.0" />
<PackageReference Include="RecursiveAI.OneMail.Client" />
paket add RecursiveAI.OneMail.Client --version 1.0.0
#r "nuget: RecursiveAI.OneMail.Client, 1.0.0"
#:package RecursiveAI.OneMail.Client@1.0.0
#addin nuget:?package=RecursiveAI.OneMail.Client&version=1.0.0
#tool nuget:?package=RecursiveAI.OneMail.Client&version=1.0.0
OneMail.Client
The raw protocol layer under the IMAP, SMTP and POP3 clients of OneMail: connections with implicit TLS, STARTTLS and COMPRESS=DEFLATE, command writers, response readers that turn every line into a typed tree, SASL, and a protocol trace with credentials redacted. It is for tools that need to drive a server by hand, including extensions no typed client knows.
Native platforms only (not browser WebAssembly). Checked against Dovecot, Postfix, Stalwart and Cyrus, and against Gmail over SMTP, IMAP and POP3; Outlook.com and arm64 protocol rows have not been run yet (https://github.com/recursive-ai-oss/onemail-csharp/blob/v1.0.0/docs/compatibility.md). The typed ImapClient, Pop3Client and SmtpClient, Mail.SendAsync and the SASL mechanisms (SCRAM, OAuth, NTLM, GSSAPI and more) are on top of it.
using RecursiveAI.OneMail.Client.Imap.Protocol;
using RecursiveAI.OneMail.Client.Protocol;
using RecursiveAI.OneMail.Client.Sasl;
using RecursiveAI.OneMail.Mime.Reading;
await using ImapRawConnection imap = await ImapRawConnection.ConnectAsync("imap.example.com", 993,
new ProtocolConnectionOptions { ImplicitTls = true });
await imap.ReadGreetingAsync();
await imap.AuthenticateAsync(new SaslPlain("user", "password"));
await imap.ExecuteAsync(ImapCommand.Create("SELECT").Mailbox("INBOX"));
// A message body goes straight from the socket into the MIME reader, without being buffered.
await imap.ExecuteAsync(ImapCommand.Create("FETCH").SequenceSet("1").Raw("(BODY.PEEK[])"), async (context, literal, ct) =>
{
using var mime = new MimeReader(literal);
while (await mime.ReadAsync(ct)) { /* headers, bodies, parts */ }
return true;
});
// Connect (STARTTLS required), authenticate with the strongest mechanism offered, send, QUIT.
SmtpSendResult r = await Mail.SendAsync(
new OutgoingMessage { From = "me@example.com", To = ["you@example.org"], Subject = "Hi", Text = "Hello" },
new SmtpClientOptions { Host = "smtp.example.com", Credentials = new SaslCredentials { UserName = "me", Password = "…" } });
foreach (var rejected in r.Rejected) Console.WriteLine($"{rejected.Address}: {rejected.Reply}");
- Credentials are never sent over an unencrypted connection unless you say so (
AllowInsecureAuthentication); the trace shows asterisks in their place. - Limits are on by default: line length, response size, literal size, list nesting and reply lines. A parsed response carries typed defects for what it had to repair; only a closed connection or a limit throws.
- Every operation has an asynchronous form with a
CancellationTokenand a synchronous twin.
await using var client = await ImapClient.ConnectAsync("imap.example.com", 993,
new ImapClientOptions { Connection = new ProtocolConnectionOptions { ImplicitTls = true } });
await client.LoginAsync("user", "password");
await client.SelectAsync("INBOX");
await foreach (ImapMessage m in client.FetchAsync(ImapSet.From(1), new ImapFetchQuery { Uid = true, Envelope = true }))
Console.WriteLine(m.Envelope!.Subject);
await foreach (ImapEvent e in client.IdleAsync(stop: token)) // appends, expunges and flag changes
Console.WriteLine(e.Kind);
Project home and source: https://github.com/recursive-ai-oss/onemail-csharp. Details: https://github.com/recursive-ai-oss/onemail-csharp/blob/v1.0.0/docs/client-protocol.md. Licence: MIT OR Apache-2.0.
This project is unaffiliated with other products named OneMail.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- RecursiveAI.OneMail (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See CHANGELOG.md in the repository.