daaki-smtp 0.1.0

An async SMTP client library
Documentation

daaki-smtp

An async SMTP client built for correctness.

Highlights

  • SMTP and LMTP — support for RFC 5321 and RFC 2033.
  • Pipelining — batches commands automatically when the server advertises it.
  • CHUNKING/BINARYMIME — send large or binary messages via BDAT without dot-stuffing.
  • Async with explicit timeouts — built on tokio. Every operation takes a Duration.
  • TLS by default — rustls-based TLS with implicit TLS (port 465) and STARTTLS.
  • Zero unsafe code — enforced by #![deny(unsafe_code)] crate-wide.

Quick Start

[dependencies]
daaki-smtp = "0.1"

Connect, authenticate, and send a message:

use daaki_smtp::{SmtpConnection, TlsMode};
use std::time::Duration;

#[tokio::main]
async fn main() -> daaki_smtp::Result<()> {
    let timeout = Duration::from_secs(30);

    let conn = SmtpConnection::connect(
        "smtp.example.com", 465, TlsMode::Implicit, timeout,
    ).await?;
    conn.auth_plain("user@example.com", "password", timeout).await?;

    let message = b"From: user@example.com\r\n\
                    To: recipient@example.com\r\n\
                    Subject: Hello\r\n\
                    \r\n\
                    Hello, world!\r\n";

    conn.send("user@example.com", &["recipient@example.com"], message, timeout).await?;
    conn.quit(timeout).await?;
    Ok(())
}

Sending with daaki-message

Build a structured email and send it in one step:

use daaki_smtp::{SmtpConnection, TlsMode, Address};
use daaki_message::{build_message, OutgoingEmail};
use std::time::Duration;

# async fn example(conn: &SmtpConnection) -> daaki_smtp::Result<()> {
let timeout = Duration::from_secs(30);
let from = Address { name: Some("Alice".into()), email: "alice@example.com".into() };

let email = OutgoingEmail {
    from: from.clone(),
    to: vec![Address { name: None, email: "bob@example.com".into() }],
    subject: Some("Hello from daaki".into()),
    text_body: Some("Plain text body".into()),
    ..Default::default()
};

let built = build_message(&email).expect("valid email");
conn.send_message(&from, &built, timeout).await?;
# Ok(())
# }

Supported Extensions

Category Extensions
Content encoding 8BITMIME, CHUNKING, BINARYMIME
Transport PIPELINING, SIZE, STARTTLS
Auth AUTH PLAIN, SASL-IR
Status ENHANCEDSTATUSCODES
Internationalization SMTPUTF8

License

The contents of this package are licensed under the terms of the MIT license.