Fixed signing in to mailboxes with characters beyond ASCII in the username or password (#1224)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-11-24 15:53:19 +01:00
1 parent f6a4348820
commit c72a1948b3
27 files changed
+1052 -30

No files matched your search

+3
View File
@@ -827,6 +827,9 @@ public static class AppIcons
/// <summary>Marks the check of which retrieved passages fit the question.</summary>
public const string PASSAGE_RELEVANCE_CHECK = LucideIcons.LIST_CHECKS;
/// <summary>Marks the encoding in which a username and a password travel, such as when signing in to a mailbox.</summary>
public const string PASSWORD_ENCODING = LucideIcons.BINARY;
/// <summary>Marks the component that reads PDF files, such as the PDFium version on the information page.</summary>
public const string PDF_READER = LucideIcons.FILE_SCAN;
@@ -1,4 +1,5 @@
using System.Net.Sockets;
using System.Text;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.Databases.IndexStore;
@@ -19,7 +20,9 @@ namespace AIStudio.Tools.Mail;
/// Every sign-in is exactly one attempt with the password. An IMAP client would otherwise try one
/// mechanism after the other and the LOGIN command last, and a directory such as Active Directory
/// counts each rejected attempt on its way to locking the account. For the same reason, nothing is
/// sent at all when the password is empty or a setting is unknown to this version.<br/><br/>
/// sent at all when the password is empty, a setting is unknown to this version, or the encoding of
/// the mailbox cannot carry the username and the password, cf. TryPrepareSignIn. AI Studio never
/// switches to another encoding on its own: only the user chooses another one.<br/><br/>
/// Before signing in, the caller has to make sure that no failed sign-in is on record for this
/// mailbox. Whatever fails arrives as MailboxConnectionException with its failure code, and nothing
/// here writes to the log: the answers of a server may name the user, so the caller logs the
@@ -111,12 +114,12 @@ public sealed class ImapMailboxConnector : IAsyncDisposable
/// </summary>
/// <param name="mailbox">The mailbox to connect to.</param>
/// <param name="password">The password, as stored in the OS keyring or just typed in.</param>
/// <param name="policy">Which mail servers the organization allows. Every connection passes here, so this is where a server it does not allow is refused.</param>
/// <param name="policy">Which mail servers the organization allows, and which encodings it names for them. Every connection passes here, so this is where a server it does not allow is refused, and where its encoding takes effect.</param>
/// <param name="token">The cancellation token.</param>
/// <exception cref="MailboxConnectionException">The connection or the sign-in failed.</exception>
public async Task ConnectAsync(DataSourceMailbox mailbox, string password, MailServerPolicy policy, CancellationToken token)
{
if (!TryGetSocketOptions(mailbox.TransportSecurity, out var socketOptions) || mailbox.AuthMethod is not MailboxAuthMethod.PASSWORD || !MailServerHosts.TryGetIdnHost(mailbox.Host, out var idnHost) || mailbox.Port is < 1 or > 65535 || string.IsNullOrWhiteSpace(mailbox.Username) || string.IsNullOrEmpty(password))
if (!TryGetSocketOptions(mailbox.TransportSecurity, out var socketOptions) || mailbox.AuthMethod is not MailboxAuthMethod.PASSWORD || policy.GetPasswordEncoding(mailbox) is not { TextEncoding: { } textEncoding } passwordEncoding || !MailServerHosts.TryGetIdnHost(mailbox.Host, out var idnHost) || mailbox.Port is < 1 or > 65535 || string.IsNullOrWhiteSpace(mailbox.Username) || string.IsNullOrEmpty(password))
throw new MailboxConnectionException(MailboxConnectionFailure.INVALID_SETTINGS, "The mailbox settings are incomplete, or this version of AI Studio does not know them.");
if (!policy.IsAllowed(mailbox.Host))
@@ -137,9 +140,13 @@ public sealed class ImapMailboxConnector : IAsyncDisposable
throw new MailboxConnectionException(failure, $"Connecting to the IMAP server failed: {failure}.", e);
}
var offersPlain = this.client.AuthenticationMechanisms.Contains(PLAIN_MECHANISM);
if (!TryPrepareSignIn(passwordEncoding, mailbox.Username, password, offersPlain, out var preparedUsername, out var preparedPassword))
throw new MailboxConnectionException(MailboxConnectionFailure.UNSUITABLE_ENCODING, "The encoding of the mailbox cannot carry the username and the password to this IMAP server.");
try
{
await this.SignInAsync(mailbox.Username, password, token);
await this.SignInAsync(textEncoding, preparedUsername, preparedPassword, offersPlain, token);
}
catch (Exception e) when (Classify(e, token) is { } failure)
{
@@ -486,11 +493,41 @@ public sealed class ImapMailboxConnector : IAsyncDisposable
return entity is TextPart textPart ? textPart.Text : null;
}
private async Task SignInAsync(string username, string password, CancellationToken token)
/// <summary>
/// Prepares the username and the password for one sign-in in the encoding of the mailbox, cf. MailServerPolicy.GetPasswordEncoding.
/// </summary>
/// <remarks>
/// A sign-in in bytes which are not the password counts as a failed attempt, just like a wrong
/// password. So nothing may be sent when the encoding cannot carry the username and the password:
/// when it lacks one of their characters, e.g., Windows-1252 has no ẞ, and when the server does not
/// offer PLAIN and the encoding is not UTF-8, since MailKit sends the LOGIN command in UTF-8,
/// whatever encoding it is handed. Text in ASCII has the same bytes in every encoding a mailbox
/// may use, cf. MailboxPasswordEncoding, so it goes through the LOGIN command as well.
/// </remarks>
/// <param name="encoding">The encoding of the mailbox.</param>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
/// <param name="offersPlain">Whether the server offers the SASL mechanism PLAIN.</param>
/// <param name="preparedUsername">The username to sign in with.</param>
/// <param name="preparedPassword">The password to sign in with.</param>
/// <returns>Whether the sign-in may go ahead.</returns>
internal static bool TryPrepareSignIn(MailboxPasswordEncoding encoding, string username, string password, bool offersPlain, out string preparedUsername, out string preparedPassword)
{
if (this.client.AuthenticationMechanisms.Contains(PLAIN_MECHANISM))
preparedPassword = password;
if (!encoding.TryPrepare(username, out preparedUsername) || !encoding.TryPrepare(password, out preparedPassword))
return false;
return offersPlain || encoding.IsUtf8 || !MailboxPasswordEncoding.DependsOnEncoding(preparedUsername, preparedPassword);
}
/// <summary>
/// Signs in once, with a username and a password which TryPrepareSignIn prepared.
/// </summary>
private async Task SignInAsync(Encoding textEncoding, string username, string password, bool offersPlain, CancellationToken token)
{
if (offersPlain)
{
await this.client.AuthenticateAsync(new SaslMechanismPlain(username, password), token);
await this.client.AuthenticateAsync(new SaslMechanismPlain(textEncoding, username, password), token);
return;
}
@@ -498,7 +535,8 @@ public sealed class ImapMailboxConnector : IAsyncDisposable
throw new MailboxConnectionException(MailboxConnectionFailure.SERVER_ERROR, "The IMAP server offers no way to sign in with a password.");
//
// With no mechanism left to try, the client signs in with the LOGIN command alone:
// With no mechanism left to try, the client signs in with the LOGIN command alone, always in
// UTF-8, cf. TryPrepareSignIn:
//
this.client.AuthenticationMechanisms.Clear();
await this.client.AuthenticateAsync(username, password, token);
@@ -1,18 +1,20 @@
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.PluginSystem;
namespace AIStudio.Tools.Mail;
/// <summary>
/// Which mail servers AI Studio may connect to, and whose mailboxes the AI may read.
/// Which mail servers AI Studio may connect to, whose mailboxes the AI may read, and in which encoding
/// a mailbox sends its username and password.
/// </summary>
/// <remarks>
/// Read anew for every decision rather than kept: both parts come from configuration plugins, which
/// Read anew for every decision rather than kept: all parts come from configuration plugins, which
/// may change while AI Studio runs.
/// </remarks>
/// <param name="AllowsOnlyOrganizationMailServers">Whether the organization allows only its own mail servers, see DataMailboxes.AllowOnlyOrganizationMailServers.</param>
/// <param name="OrganizationHosts">The hosts of the mail servers which the configuration plugins offer.</param>
public sealed record MailServerPolicy(bool AllowsOnlyOrganizationMailServers, IReadOnlyList<string> OrganizationHosts)
/// <param name="OrganizationServers">The mail servers which the configuration plugins offer.</param>
public sealed record MailServerPolicy(bool AllowsOnlyOrganizationMailServers, IReadOnlyList<OrganizationMailServer> OrganizationServers)
{
/// <summary>
/// Every server: what holds as long as no organization rules otherwise.
@@ -26,7 +28,7 @@ public sealed record MailServerPolicy(bool AllowsOnlyOrganizationMailServers, IR
/// <returns>The policy.</returns>
public static MailServerPolicy Read(SettingsManager settingsManager) => new(
settingsManager.ConfigurationData.MailboxSettings.AllowOnlyOrganizationMailServers,
PluginFactory.GetMailboxProviders().Select(provider => provider.Host).ToList());
PluginFactory.GetMailboxProviders().Select(provider => new OrganizationMailServer(provider.Host, provider.PasswordEncoding)).ToList());
/// <summary>
/// Whether AI Studio may connect to a server, and the AI read the mailboxes on it.
@@ -37,5 +39,39 @@ public sealed record MailServerPolicy(bool AllowsOnlyOrganizationMailServers, IR
/// </remarks>
/// <param name="host">The host of the server.</param>
/// <returns>True when the server is allowed.</returns>
public bool IsAllowed(string host) => !this.AllowsOnlyOrganizationMailServers || this.OrganizationHosts.Any(organizationHost => MailServerHosts.AreSame(organizationHost, host));
public bool IsAllowed(string host) => !this.AllowsOnlyOrganizationMailServers || this.OrganizationServers.Any(server => MailServerHosts.AreSame(server.Host, host));
/// <summary>
/// The encoding the organization names for a server.
/// </summary>
/// <remarks>
/// Found by the host, like IsAllowed: the user may have typed the host rather than chosen the
/// mail server of the organization. It holds whether or not the organization allows only its own
/// mail servers.
/// </remarks>
/// <param name="host">The host of the server.</param>
/// <returns>The encoding, or null when the organization names none for this server.</returns>
public MailboxPasswordEncoding? GetOrganizationPasswordEncoding(string host) => this.OrganizationServers
.FirstOrDefault(server => server.PasswordEncoding is not null && MailServerHosts.AreSame(server.Host, host))?
.PasswordEncoding;
/// <summary>
/// The encoding in which a mailbox sends its username and password.
/// </summary>
/// <remarks>
/// The encoding the organization names for the server comes first: it knows what its server
/// expects, and it may name the encoding only after the mailbox was added. Every sign-in, the
/// connection test and the synchronization alike, takes the encoding from here.
/// </remarks>
/// <param name="mailbox">The mailbox.</param>
/// <returns>The encoding.</returns>
public MailboxPasswordEncoding GetPasswordEncoding(DataSourceMailbox mailbox) => this.GetPasswordEncoding(mailbox.Host, mailbox.PasswordEncoding);
/// <summary>
/// The encoding in which a mailbox on a server sends its username and password, cf. GetPasswordEncoding of a mailbox.
/// </summary>
/// <param name="host">The host of the server.</param>
/// <param name="mailboxEncoding">The encoding of the mailbox.</param>
/// <returns>The encoding.</returns>
public MailboxPasswordEncoding GetPasswordEncoding(string host, MailboxPasswordEncoding mailboxEncoding) => this.GetOrganizationPasswordEncoding(host) ?? mailboxEncoding;
}
@@ -34,4 +34,9 @@ public enum MailboxConnectionFailure
/// The organization allows only its own mail servers, and the server of the mailbox is none of them. Nothing was sent to the server.
/// </summary>
SERVER_NOT_ALLOWED,
/// <summary>
/// The encoding of the mailbox cannot carry the username or the password to the server: it lacks one of their characters, or the server takes no other encoding than UTF-8 for them. Nothing was sent to the server.
/// </summary>
UNSUITABLE_ENCODING,
}
@@ -21,6 +21,7 @@ public static class MailboxConnectionFailureExtensions
MailboxConnectionFailure.SERVER_ERROR => TA("The server reported an error. Please try again later."),
MailboxConnectionFailure.INVALID_SETTINGS => TB("The settings of this mailbox are incomplete, or they were made by a newer version of AI Studio."),
MailboxConnectionFailure.SERVER_NOT_ALLOWED => TA("Your organization allows mailboxes only on its own mail servers, and this server is none of them. AI Studio does not connect to it, and the AI does not read this mailbox."),
MailboxConnectionFailure.UNSUITABLE_ENCODING => TA("The chosen encoding cannot carry your username or your password to this server: it lacks one of their characters, or the server accepts no other encoding than UTF-8. AI Studio did not try to sign in, so that your account is not locked. Choose another encoding in the server details of the mailbox, or ask your IT department which one the server expects."),
_ => TB("The connection to the server failed for an unknown reason."),
};
@@ -0,0 +1,233 @@
using System.Globalization;
using System.Text;
using System.Text.Json.Serialization;
namespace AIStudio.Tools.Mail;
/// <summary>
/// The encoding in which AI Studio sends the username and the password of a mailbox.
/// </summary>
/// <remarks>
/// The standard for signing in with a password demands UTF-8 (RFC 4616), but a mail server compares
/// the bytes it receives with what it stored, and depending on its configuration, it may decode them
/// in another encoding. Microsoft Exchange, e.g., may expect the code page of its Windows system:
/// Windows-1252 in Western Europe, Windows-1254 in Turkey, or Shift-JIS in Japan. ASCII comes out the
/// same in all of them, so only users whose username or password holds other characters notice.<br/><br/>
/// AI Studio therefore offers every encoding .NET knows which keeps ASCII as it is, stored by its name,
/// e.g., "windows-1254". UTF-16, UTF-32, UTF-7, and the EBCDIC code pages are left out: they change
/// ASCII, and SASL PLAIN separates its parts with zero bytes, which UTF-16 and UTF-32 would break.<br/><br/>
/// A name this version does not know, e.g., one written into the settings by hand, keeps its name, so
/// that it is stored as it was, but signs in nowhere, cf. IsKnown. Falling back to UTF-8 instead would
/// sign in with bytes which may not be the password, and every such attempt counts as a failed sign-in,
/// which can lock the account. Two values are equal when their names are, cf. Name.
/// </remarks>
[JsonConverter(typeof(MailboxPasswordEncodingJsonConverter))]
public readonly record struct MailboxPasswordEncoding
{
/// <summary>
/// The characters of ASCII, which every encoding a mailbox may use has to keep as they are.
/// </summary>
private static readonly string ASCII_TEXT = new(Enumerable.Range(0, 128).Select(code => (char)code).ToArray());
/// <summary>
/// The bytes of ASCII_TEXT in ASCII.
/// </summary>
private static readonly byte[] ASCII_BYTES = Encoding.ASCII.GetBytes(ASCII_TEXT);
/// <summary>
/// The encoding of a new mailbox, and of one stored before the setting existed: UTF-8, which AI Studio always used until then.
/// </summary>
public static readonly MailboxPasswordEncoding DEFAULT;
/// <summary>
/// All encodings a mailbox may use: UTF-8 first, the others in alphabetical order of their names.
/// </summary>
public static readonly IReadOnlyList<MailboxPasswordEncoding> ALL;
static MailboxPasswordEncoding()
{
// .NET knows the code pages of Windows and most others only once their provider is registered:
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
DEFAULT = FromName("utf-8");
ALL = Encoding.GetEncodings()
.Select(info => FromName(info.Name))
.Where(encoding => encoding.IsKnown)
.Distinct()
.OrderBy(encoding => encoding != DEFAULT)
.ThenBy(encoding => encoding.Name, StringComparer.Ordinal)
.ToList();
}
private MailboxPasswordEncoding(string name, Encoding? textEncoding)
{
this.Name = name;
this.TextEncoding = textEncoding;
}
/// <summary>
/// The name of the encoding: the one .NET gives it, e.g., "windows-1252", or, for an encoding this
/// version does not know, the name as it was written.
/// </summary>
public string Name => field ?? string.Empty;
/// <summary>
/// The encoding to hand to the IMAP client. It refuses what it cannot encode instead of replacing
/// it, e.g., with a question mark: a password sent with a replaced character is not the password.
/// </summary>
/// <value>The encoding, or null when this version does not know it.</value>
public Encoding? TextEncoding { get; }
/// <summary>
/// Whether this version knows the encoding, and so whether a mailbox may sign in with it.
/// </summary>
public bool IsKnown => this.TextEncoding is not null;
/// <summary>
/// Whether the encoding is UTF-8, the only one the LOGIN command of the IMAP client sends.
/// </summary>
public bool IsUtf8 => this.TextEncoding?.CodePage == Encoding.UTF8.CodePage;
/// <summary>
/// Finds the encoding of a name.
/// </summary>
/// <param name="name">The name of the encoding, e.g., "windows-1252", in any case and with spaces around it.</param>
/// <returns>The encoding. When .NET does not know the name, or when the encoding changes ASCII, one which signs in nowhere, cf. IsKnown.</returns>
public static MailboxPasswordEncoding FromName(string? name)
{
var unknown = new MailboxPasswordEncoding(name ?? string.Empty, null);
if (string.IsNullOrWhiteSpace(name))
return unknown;
try
{
var candidate = Encoding.GetEncoding(name.Trim(), EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
return candidate.GetBytes(ASCII_TEXT).AsSpan().SequenceEqual(ASCII_BYTES) ? new(candidate.WebName, candidate) : unknown;
}
// Thrown for a name .NET does not know, and for an encoding which lacks a character of ASCII.
// EncoderFallbackException is one of them:
catch (ArgumentException)
{
return unknown;
}
// Thrown for an encoding .NET knows but no longer supports, such as UTF-7:
catch (NotSupportedException)
{
return unknown;
}
}
/// <summary>
/// Whether the bytes of a username and a password depend on the encoding: only characters beyond ASCII do.
/// </summary>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
/// <returns>True when either holds a character beyond ASCII.</returns>
public static bool DependsOnEncoding(string username, string password) => !Ascii.IsValid(username) || !Ascii.IsValid(password);
/// <summary>
/// The encoding to offer for one more connection test after the server refused a username or a
/// password with characters beyond ASCII.
/// </summary>
/// <remarks>
/// A server which expects another encoding than UTF-8 mostly expects the code page of the Windows
/// system it runs on, and that is mostly the code page of the region its users live in: the ANSI
/// code page of Windows for the language of the operating system, e.g., windows-1252 for de-DE or
/// windows-1254 for tr-TR. When the test used that one already, UTF-8 comes next. An encoding which
/// lacks a character of the username or the password is never offered. It is only an offer: the
/// user decides, and every test is one attempt to sign in.
/// </remarks>
/// <param name="localeTag">The language of the operating system, e.g., "de-DE".</param>
/// <param name="testedEncoding">The encoding the refused test used.</param>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
/// <returns>The encoding, or null when there is none to offer.</returns>
public static MailboxPasswordEncoding? Suggest(string localeTag, MailboxPasswordEncoding testedEncoding, string username, string password)
{
if (!DependsOnEncoding(username, password))
return null;
foreach (var candidate in new[] { GetRegionalEncoding(localeTag), DEFAULT })
{
if (candidate is not { } encoding || encoding == testedEncoding)
continue;
if (encoding.TryPrepare(username, out _) && encoding.TryPrepare(password, out _))
return encoding;
}
return null;
}
/// <summary>
/// Prepares a username or a password for this encoding.
/// </summary>
/// <remarks>
/// For every encoding but UTF-8, the text is normalized first (NFC): an ä may arrive as an a
/// followed by a combining diaeresis, e.g., from a password manager, and the code pages mostly have
/// only the composed ä. UTF-8 takes the text as it is, as AI Studio always sent it.
/// </remarks>
/// <param name="text">The username or the password.</param>
/// <param name="prepared">The text to sign in with.</param>
/// <returns>Whether this version knows the encoding and it has every character of the text.</returns>
public bool TryPrepare(string text, out string prepared)
{
prepared = text;
if (this.TextEncoding is not { } textEncoding)
return false;
try
{
if (!this.IsUtf8)
prepared = text.Normalize(NormalizationForm.FormC);
textEncoding.GetByteCount(prepared);
return true;
}
// Thrown for a character the encoding lacks, and for a lone surrogate, which no encoding has.
// EncoderFallbackException is one of them:
catch (ArgumentException)
{
prepared = text;
return false;
}
}
/// <inheritdoc />
public bool Equals(MailboxPasswordEncoding other) => string.Equals(this.Name, other.Name, StringComparison.Ordinal);
/// <inheritdoc />
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(this.Name);
/// <summary>
/// The name of the encoding, as the mailbox dialog shows it, cf. Name.
/// </summary>
public override string ToString() => this.Name;
/// <summary>
/// The ANSI code page of Windows for a language, cf. Suggest.
/// </summary>
/// <param name="localeTag">The language, e.g., "tr-TR".</param>
/// <returns>The encoding, or null for an unknown language and for one without a code page of its own, such as Hindi.</returns>
private static MailboxPasswordEncoding? GetRegionalEncoding(string localeTag)
{
if (string.IsNullOrWhiteSpace(localeTag))
return null;
try
{
var codePage = CultureInfo.GetCultureInfo(localeTag.Trim()).TextInfo.ANSICodePage;
return codePage is 0 ? null : FromName(Encoding.GetEncoding(codePage).WebName);
}
// Thrown for a language .NET does not know, and for a code page it does not support.
// CultureNotFoundException is one of them:
catch (Exception e) when (e is ArgumentException or NotSupportedException)
{
return null;
}
}
}
@@ -0,0 +1,28 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace AIStudio.Tools.Mail;
/// <summary>
/// Stores the password encoding of a mailbox by its name, e.g., "windows-1252".
/// </summary>
/// <remarks>
/// A name this version does not know is read as it is and written back unchanged, cf.
/// MailboxPasswordEncoding.IsKnown. Anything else than a name, e.g., a number written by hand, is no
/// encoding at all: the mailbox then signs in nowhere, but the other settings are read as usual.
/// </remarks>
public sealed class MailboxPasswordEncodingJsonConverter : JsonConverter<MailboxPasswordEncoding>
{
/// <inheritdoc />
public override MailboxPasswordEncoding Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType is JsonTokenType.String)
return MailboxPasswordEncoding.FromName(reader.GetString());
reader.Skip();
return MailboxPasswordEncoding.FromName(null);
}
/// <inheritdoc />
public override void Write(Utf8JsonWriter writer, MailboxPasswordEncoding value, JsonSerializerOptions options) => writer.WriteStringValue(value.Name);
}
@@ -41,4 +41,14 @@ public static class MailboxProviderTemplates
// Every organization runs a server of its own, and IMAP ships switched off:
new("Microsoft Exchange Server", string.Empty, IMAPS_PORT, MailboxTransportSecurity.SSL_ON_CONNECT, MailboxUsernameFormat.DOMAIN_ACCOUNT, MailboxProviderRequirements.ADMIN_ACTIVATION, "https://learn.microsoft.com/en-us/exchange/clients/pop3-and-imap4/configure-imap4", string.Empty),
];
/// <summary>
/// Finds the well-known provider whose server a host names, however the host was written.
/// </summary>
/// <remarks>
/// Microsoft Exchange Server never matches: every organization runs a server of its own.
/// </remarks>
/// <param name="host">The host of a mailbox.</param>
/// <returns>The provider, or null when the host belongs to none of them.</returns>
public static MailboxProviderTemplate? FindByHost(string host) => ALL.FirstOrDefault(template => template.Host.Length > 0 && MailServerHosts.AreSame(template.Host, host));
}
@@ -0,0 +1,8 @@
namespace AIStudio.Tools.Mail;
/// <summary>
/// What MailServerPolicy needs to know about a mail server which a configuration plugin offers.
/// </summary>
/// <param name="Host">The host of the server.</param>
/// <param name="PasswordEncoding">The encoding the server expects for usernames and passwords, cf. DataMailboxProvider.PasswordEncoding, or null when the organization did not say.</param>
public sealed record OrganizationMailServer(string Host, MailboxPasswordEncoding? PasswordEncoding);