Skip to main content

Crate postcrate_core

Crate postcrate_core 

Source
Expand description

Tokio-native SMTP capture engine for local development, integration tests, and CI.

postcrate-core listens for SMTP, parses incoming mail, stores it in SQLite, and exposes everything over a small HTTP API. It has no dependency on a UI or on any third-party mail service.

§Quick start

use std::sync::Arc;
use postcrate_core::{CoreConfig, LogSink, Service};

let cfg = CoreConfig::for_data_dir("/tmp/postcrate")?;
let service = Service::build(cfg, Arc::new(LogSink)).await?;
service.start_all().await?;

After Service::start_all, the configured SMTP listeners are accepting mail and the HTTP API is serving requests under /api/v1. Subscribe to live events by passing a custom EventSink instead of LogSink.

§Public surface

The public API is deliberately narrow: the Service type plus a handful of input / output structs re-exported from this module. Everything else is pub(crate). See the Service type for the full method set, and the postcrate-docs repository for the architecture notes, HTTP-API reference, and SMTP-extension table.

§Crate features

FeatureEffect
tlsEnables STARTTLS and implicit-TLS listeners (RFC 8314). Off by default.

Re-exports§

pub use crate::config::BindHost;
pub use crate::config::CoreConfig;
pub use crate::error::Error;
pub use crate::error::Result;
pub use crate::events::BounceKind;
pub use crate::events::ChannelSink;
pub use crate::events::CoreEvent;
pub use crate::events::EventSink;
pub use crate::events::LogSink;
pub use crate::events::MailboxStateChange;
pub use crate::events::ServerStatus;
pub use crate::matcher::EmailPredicate;
pub use crate::matcher::HeaderPredicate;
pub use crate::matcher::MatchResult;
pub use crate::matcher::WaitOutcome;
pub use crate::recording::Recording;
pub use crate::recording::RecordedEnvelope;
pub use crate::recording::RecordedMessage;
pub use crate::recording::RECORDING_VERSION;
pub use crate::rendering::a11y::A11yFinding;
pub use crate::rendering::a11y::A11yReport;
pub use crate::rendering::lint::LintReport;
pub use crate::rendering::lint::LintWarning;
pub use crate::rendering::profile::Fidelity;
pub use crate::rendering::profile::Profile;
pub use crate::rendering::profile::RenderedPreview;
pub use crate::scenarios::auth::AuthReport;
pub use crate::scenarios::auth::AuthVerdict;
pub use crate::scenarios::links::LinkCounts;
pub use crate::scenarios::links::LinkKind;
pub use crate::scenarios::links::LinkReport;
pub use crate::scenarios::list_unsub::UnsubFinding;
pub use crate::scenarios::list_unsub::UnsubReport;
pub use crate::scenarios::list_unsub::UnsubUri;
pub use crate::scenarios::spam::SpamFactor;
pub use crate::scenarios::spam::SpamReport;
pub use crate::scenarios::spam::SpamVerdict;
pub use crate::tagging::EmailTag;
pub use crate::service::Service;

Modules§

config
Static configuration for a Service. Resolved once at construction. Anything the user can change at runtime lives in the settings table, not here.
error
Crate-wide error type. Every public method on crate::Service returns Result<_, Error>. Boundary adapters (the built-in Axum routes, downstream UI shims) convert this into HTTP status codes or whatever shape the surrounding host expects.
events
UI-agnostic event emission. Consumers — desktop shells, CLI tail commands, integration tests — implement EventSink and pass it to crate::Service::build. The engine never touches a UI framework directly.
matcher
Email predicates + structured matching.
recording
.postcrate recording format (/31/32).
rendering
Multi-client rendering preview engine (..40).
scenarios
Scenario inspectors that produce diagnostics about a captured email after it’s been parsed. None of these touch the network — they’re heuristics over the headers + bodies the engine already has on disk.
service
The single public façade. The built-in HTTP routes, downstream command shims, and CLI subcommands all speak only to this type.
tagging
Auto-tagging.

Structs§

AdvancedPrefs
AgentPrefs
AttachmentMeta
AuditEntry
BackendSettings
BounceRule
ChaosConfig
CreateEphemeralInput
CreateForwardingRule
CreateMailboxInput
CreateWebhook
EmailDetail
EmailSummary
EphemeralHandle
ForwardingRule
InboxPrefs
Mailbox
A mailbox row joined with its current message count.
NetworkPrefs
RelayConfig
UpdateMailboxInput
Webhook

Enums§

MailboxKind
SettingsPatch
One-of patch — exactly one section is set per call.
SettingsSection