Skip to main content

Crate rusted_mail

Crate rusted_mail 

Source
Expand description

Protocol and storage engine for the Rusted Mail stack.

rusted-mail contains the platform-independent implementation shared by the project’s native integrations. It provides the protocol, persistence, synchronization, provider-discovery, and message-processing machinery for IMAP, SMTP, POP3, and JMAP mail clients. It does not link JNI or produce an Android shared library.

§Package structure

The workspace separates responsibilities into three packages:

  • rusted-mail — this protocol and storage engine;
  • rusted-mail-jni — Java Native Interface entry points and asynchronous callback handling;
  • rusted-mail-android — the libmail_jni.so Android packaging layer.

Applications integrating through Kotlin or Java should normally consume rusted-mail-android. The engine’s Rust API is deliberately kept separate from Android lifecycle and ABI concerns.

§Cargo features

No optional integration is enabled by default.

  • turso-native-sync enables Turso’s native synchronization support.
  • crypto-openpgp enables OpenPGP message processing.
  • crypto-smime enables S/MIME message processing.

Cryptographic features add substantial dependency trees and should be enabled only when the consuming application exposes the corresponding functionality.

§Quick start

The typed API owns session handles and keeps the JNI-oriented JSON protocol out of application code:

use rusted_mail::{AccountConfig, Credentials, MailEngine, ServerConfig};

let account = AccountConfig::builder("alice@example.com")
    .credentials(Credentials::password("application-password"))
    .imap(ServerConfig::tls("imap.example.com", 993))
    .smtp(ServerConfig::start_tls("smtp.example.com", 587))
    .build()?;

let engine = MailEngine::new();
let session = engine.connect_imap(account).await?;
for mailbox in session.list_mailboxes().await? {
    println!("{}", mailbox.name);
}
session.close().await?;

§Errors

Operations return Error. Error::public converts an error into the serializable MailError envelope, whose ErrorCode is stable across language boundaries.

Re-exports§

pub use api::AccountConfig;
pub use api::AccountConfigBuilder;
pub use api::Attachment;
pub use api::BodyOptions;
pub use api::Credentials;
pub use api::FetchOptions;
pub use api::ImapSession;
pub use api::JmapAccountConfig;
pub use api::JmapAccountConfigBuilder;
pub use api::JmapEmail;
pub use api::JmapEmailQuery;
pub use api::JmapMailbox;
pub use api::JmapSession;
pub use api::MailEngine;
pub use api::MailEngineBuilder;
pub use api::MailboxInfo;
pub use api::MailboxStats;
pub use api::Message;
pub use api::MessageBody;
pub use api::MessageBuilder;
pub use api::MessageSet;
pub use api::MessageSummary;
pub use api::Pop3AccountConfig;
pub use api::Pop3AccountConfigBuilder;
pub use api::Pop3Capabilities;
pub use api::Pop3MailboxStatus;
pub use api::Pop3Message;
pub use api::Pop3MessageInfo;
pub use api::Pop3ServerConfig;
pub use api::Pop3Session;
pub use api::Pop3TlsMode;
pub use api::ProviderDiscovery;
pub use api::ProviderDiscoverySource;
pub use api::SearchOptions;
pub use api::SendResult;
pub use api::ServerConfig;
pub use api::SpecialFolders;
pub use api::TlsMode;
pub use error::Error;
pub use error::ErrorCode;
pub use error::MailError;

Modules§

api
Typed, platform-independent API for mail applications. Typed, platform-independent API for mail applications.
error
Stable error codes and error envelopes shared across integration layers. Error types exposed by the engine.