Skip to content

Configuration ​

GmailConfig ​

dev.reapermaga.mailkt.gmail

PropertyTypeDefaultDescription
clientIdStringGoogle OAuth client ID.
clientSecretStringGoogle OAuth client secret.
allowedRedirectUrisSet<URI>Exact registered callback URIs. Must not be empty.
kotlin
Gmail(
    config: GmailConfig,
    tokenStore: TokenStore,
    authorizationSessionStore: AuthorizationSessionStore,
    connector: MailboxConnector = DefaultMailboxConnector,
)

OutlookConfig ​

dev.reapermaga.mailkt.outlook

PropertyTypeDefaultDescription
clientIdStringEntra application ID.
clientSecretStringClient secret.
allowedRedirectUrisSet<URI>Exact registered callback URIs. Must not be empty.
authorityStringhttps://login.microsoftonline.com/common/Authority URL. Must be HTTPS.
enableSendingBooleanfalseRequests SMTP.Send and enables the outbox.
kotlin
Outlook(
    config: OutlookConfig,
    tokenStore: TokenStore,
    authorizationSessionStore: AuthorizationSessionStore,
    connector: MailboxConnector = DefaultMailboxConnector,
)

connector is an extension point for tests or custom transports; the default builds the managed IMAP/SMTP mailbox.

Provider client functions ​

Gmail and Outlook expose the same three functions:

FunctionReturnsDescription
beginAuthorization(expectedEmail, redirectUri)AuthorizationRequestValidates the URI and stores a pending session.
completeAuthorization(callback)MailboxIdValidates and exchanges the callback, stores tokens.
open(email, options = MailboxOptions())MailboxConnects using stored tokens and silent refresh.

Redirect URI rules ​

  • Scheme https, or http on localhost, 127.0.0.1 or [::1].
  • No query string, no fragment.
  • Must be in allowedRedirectUris exactly.

MailboxOptions ​

PropertyTypeDefaultDescription
connectionPolicyConnectionPolicyConnectionPolicy()Recovery behavior.
outboxEnabledBooleantrueDisable to force outbox == null.
registryMailboxRegistry?nullEnforces unique identities.

ConnectionPolicy ​

PropertyTypeDefaultDescription
keepAliveIntervalDuration30.secondsHealth check interval. Must be positive.
attemptTimeoutDuration30.secondsTimeout per connection attempt. Must be positive.
maxReconnectAttemptsInt5Attempts before Failed. At least 1.
initialBackoffDuration1.secondsBackoff before the first retry, doubling each attempt.
maxBackoffDuration30.secondsBackoff cap.
jitterFractionDouble0.2Random jitter, within 0..1.

backoff(attempt, random) exposes the computed delay, which is useful in tests.

Endpoints ​

ProviderIMAPSMTP
Gmailimap.gmail.com:993 (TLS)smtp.gmail.com:465 (TLS)
Outlookoutlook.office365.com:993 (TLS)smtp.office365.com:587 (STARTTLS)

Released under the MIT License.