diff --git a/src/client/mod.rs b/src/client/mod.rs index 78d8167..5870679 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -292,7 +292,7 @@ impl Client { } /// Connects to the configured server - fn connect(&mut self) -> SmtpResult { + pub fn connect(&mut self) -> SmtpResult { // Connect should not be called when the client is already connected if self.stream.is_some() { close_and_return_err!("The connection is already established", self); diff --git a/src/lib.rs b/src/lib.rs index 147577f..501e1d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,6 +110,26 @@ //! let result = client.send(email); //! assert!(result.is_ok()); //! ``` +//! +//! ### Lower level +//! +//! You can also send commands, here is a simple email transaction without error handling: +//! +//! ```rust,no_run +//! use smtp::client::{Client, ClientBuilder}; +//! use smtp::SMTP_PORT; +//! use std::net::TcpStream; +//! +//! let mut email_client: Client = ClientBuilder::new(("localhost", SMTP_PORT)).build(); +//! let _ = email_client.connect(); +//! let _ = email_client.ehlo(); +//! let _ = email_client.mail("user@example.com"); +//! let _ = email_client.rcpt("user@example.org"); +//! let _ = email_client.data(); +//! let _ = email_client.message("Test email"); +//! let _ = email_client.quit(); +//! ``` + #![feature(plugin, core, io, collections, net, str_words)] #![deny(missing_docs)]