Rust

client

Module

The SMTP session.

Contents

use utopia_smtp::Client;
Rust
pub struct Client<T: Transport>

An RFC 5321 client submitting mail to one server, over one connection, opened on first use and reopened after it was dropped.

Rust
use utopia_smtp::auth::Plain;
use utopia_smtp::{Address, Client, Encryption, Message, TcpTransport, Tls};

let mut client = Client::new(TcpTransport::new("smtp.example.test", 587, Tls::default()))
    .with_domain("app.example.test")
    .with_authenticator(Plain::new("jane", "secret"))
    .with_encryption(Encryption::StartTls);

let message = Message::builder(Address::new("jane@example.test", "Jane")?, "Hello")
    .to(Address::new("john@example.test", "")?)
    .text("Hi John")
    .build()?;

let delivery = client.send(&message).await?;
assert!(delivery.is_complete());
client.close().await;
Compiles in CI; needs a running service to execute.
use utopia_smtp::Delivery;
Rust
pub struct Delivery

What one send achieved. RFC 5321 lets a server refuse some recipients and accept others, and the message still reaches the rest.