Build Status

samotop 0.9.0

This is an SMTP server library with focus on privacy. There is also an actual SMTP server - see samotop-server

SMTP Relay Server (MTA) library for Rust with focus on spam elimination and privacy. The motivation is to revive e-mail infrastructure and architecture, address current problems and allow new systems to integrate SMTP. It's called SaMoToP, which could be a nice Czech word.

Status

Reaching stable. The API builds on async/await to offer a convenient asynchronous interface.

Installation

Usage

See the docs on docs.rs.

Add this to your Cargo.toml:

toml [dependencies.samotop] version = "0"

Note that the API is still unstable. Please use the latest release.

There are a few interesting provisions one could take away from Samotop: * The server (through samotop::server::Server) - it takes IP:port's to listen on() and you can then serve() your own implementation of a TcpService. * The SMTP service (SmtpService) - it takes an async IO and provides an SMTP service defined by SessionService. * The low level SmtpCodec - it translates between IO and a Stram of ReadControl and a Sink of WriteControl. It handles SMTP mail data as well. * The SMTP session parser (SmtpParser) - it takes &str and returns parsed commands or session. * The SMTP session and domain model (samotop::model::session, samotop::model::smtp) - these describe the domain and behavior. * The mail handling stuff that is yet to be written (MailService)...

SMTP Server

You can run a plaintext SMTP service without support for STARTTLS.

rust extern crate async_std; extern crate env_logger; extern crate samotop; use samotop::server::Server; use samotop::service::tcp::DummyTcpService; fn main() { env_logger::init(); let mail = samotop::service::mail::default::DefaultMailService; let sess = samotop::service::session::StatefulSessionService::new(mail); let svc = samotop::service::tcp::SmtpService::new(sess); let svc = samotop::service::tcp::TlsEnabled::disabled(svc); let srv = samotop::server::Server::on("localhost:25").serve(svc); async_std::task::block_on(srv).unwrap() }

To enable TLS, provide a rustls TlsAcceptor. Alternatively, implement TlsEnabled for another TLS library. See the samotop-server for fullexample with TLS enabled.

Dummy server

Any TCP service can be served. See the docs for TcpService. Run it with RUST_LOG=trace to display trace log. Use this to understand how networking IO is handled.

rust extern crate async_std; extern crate env_logger; extern crate samotop; use samotop::server::Server; use samotop::service::tcp::DummyTcpService; fn main() { env_logger::init(); let mut srv = Server::on("localhost:0").serve(DummyTcpService); async_std::task::block_on(srv).unwrap() }

Development

Refresh README from docs: $ cargo readme > README.md

Status

We've got a decent SMTP command parser written as a PEG grammar. The model is tightly nit from the RFCs. An async-std based server will hear your SMTP commands, drive the SMTP state machine and correct you if you step aside. Once a mail session is ready, the mail data are currently dumped to the console. After that, you can do it again. See the crate documentation for API status. The samotop crate is published on crates.io. The executable is not very useful yet except for debugging SMTP itself until common MDA/MTA features are implemented.

Done

To do

Company

In Rust world I have so far found mostly SMTP clients.

SMTP server

Other

License

MIT