[][src]Crate samotop_delivery

samotop-delivery is an implementation of the smtp protocol client in Rust.

Example

pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;

use samotop_delivery::prelude::{
    Envelope, SmtpClient, Transport,
};

async fn smtp_transport_simple() -> Result<()> {
    let envelope = Envelope::new(
            Some("user@localhost".parse().unwrap()),
            vec!["root@localhost".parse().unwrap()],
            "id".to_string(),
        ).unwrap();
    let message = "From: user@localhost\r\n\
                    Content-Type: text/plain\r\n\
                    \r\n\
                    Hello example"
                    .as_bytes();
    let client = SmtpClient::new("127.0.0.1:2525").unwrap();
     
    // Create a client, connect and send
    client.connect_and_send(envelope, message).await.unwrap();    

    Ok(())
}

Modules

file

The file transport writes the emails to the given directory. The name of the file will be message_id.txt. It can be useful for testing purposes, or if you want to keep track of sent messages.

prelude
sendmail

The sendmail transport sends the envelope using the local sendmail command.

smtp

The SMTP transport sends emails using the SMTP protocol.

stub

The stub transport only logs message envelope and drops the content. It can be useful for testing purposes.

types

Traits

MailDataStream
Transport

Transport method for emails