Skip to main content

Crate mailbridge

Crate mailbridge 

Source
Expand description

Provider-neutral transactional email client.

§Example

use mailbridge::{EmailMessage, HyvorRelayProvider, MailClient, MailbridgeConfig};

let config = MailbridgeConfig::from_env()?;
let provider = HyvorRelayProvider::from_config(&config)?;
let client = MailClient::try_from_config(provider, &config).await?;

let message = EmailMessage::builder()
    .from("Hashcode", "no-reply@hashcode-fibration.com")?
    .to("User", "user@example.com")?
    .subject("Relay test")
    .text("This is a test email.")
    .build()?;

let receipt = client.send(message).await?;
println!("{}", receipt.message_id());

§Queue Backends

queue-memory is intended for tests, local development, and workloads that can tolerate losing queued mail on process restart. Use queue-sqlite for single-node durable queueing and queue-postgres for multi-worker durable queueing in applications that already operate PostgreSQL. Use queue-scylla for high-throughput ScyllaDB deployments where bucket count, lease timeout, replication, compaction, and dead-letter retention are tuned by the owning application.

Future provider flags (sendgrid, sendpulse, and mailgun) expose types that fail with a configuration error until full provider implementations are added.

Live durable-backend tests are environment gated:

  • MAILBRIDGE_TEST_POSTGRES_URL for PostgreSQL.
  • MAILBRIDGE_TEST_SCYLLA_URI, MAILBRIDGE_TEST_SCYLLA_KEYSPACE, and MAILBRIDGE_TEST_SCYLLA_TABLE for ScyllaDB.

Structs§

Attachment
EmailAddress
EmailMessage
EmailMessageBuilder
HyvorRelayProvider
MailClient
MailClientBuilder
MailRateLimiter
MailbridgeConfig
MailbridgeConfigBuilder
MailgunProvider
MessageId
PostgresQueue
QueueHandle
QueueId
QueueItem
QueueWorker
QueueWorkerConfig
QueuedEmail
RateLimitConfig
ScyllaQueue
SendGridProvider
SendPulseProvider
SendReceipt
SmtpClient
SmtpConfig
SqliteQueue
TelemetryFields

Enums§

DeliveryMode
MailError
QueueBackend
SendStatus
TelemetryEvent

Traits§

MailProvider
MailQueue

Type Aliases§

Result