Skip to main content

Crate direct_to_mx

Crate direct_to_mx 

Source
Expand description

§direct_to_mx

Direct-to-MX email delivery with DKIM signing, IPv4 forcing, MX fallback, DKIM key generation, and DNS verification.

This crate provides a builder-based API for sending emails directly to recipient MX servers without relying on an intermediate relay or third-party API. It handles MX resolution, IPv4-only connections (to avoid IPv6 PTR rejections), opportunistic TLS, DKIM signing with relaxed/relaxed canonicalization, and automatic fallback across multiple MX hosts.

§Example

use direct_to_mx::{DirectToMx, Body, DkimOptions};

let mailer = DirectToMx::builder()
    .from("no-reply@mail.example.com")
    .ehlo_hostname("mail.example.com")
    .dkim(DkimOptions {
        selector: "sel1".into(),
        domain: "mail.example.com".into(),
        private_key_pem: std::fs::read_to_string("/path/to/dkim.pem").unwrap(),
    })
    .build()?;

mailer.send("user@gmail.com", "Hello", Body::text("Hi there")).await?;

Re-exports§

pub use dkim::DkimKeyPair;
pub use dkim::generate_dkim_keypair;
pub use dns::DnsCheck;
pub use dns::DnsCheckResult;
pub use dns::DnsCheckStatus;
pub use dns::DnsVerifyOptions;
pub use dns::DnsVerifyReport;
pub use dns::verify_dns;
pub use error::DirectToMxError;

Modules§

dkim
dns
error

Structs§

Attachment
A file attachment.
BulkResult
Result of a single delivery within a bulk send.
DirectToMx
The configured mailer. Obtain one via DirectToMx::builder().
DirectToMxBuilder
Builder for DirectToMx.
DkimOptions
DKIM signing configuration.
OutboundMessage
A single outbound message for DirectToMx::send_bulk.

Enums§

Body
Email body — HTML, plain text, or both (multipart/alternative).

Constants§

DEFAULT_CONCURRENCY
Default number of concurrent SMTP deliveries for DirectToMx::send_bulk.