diff --git a/Cargo.toml b/Cargo.toml index 668e113..1c6a0f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "smtp" -version = "0.0.2" +version = "0.0.3" authors = ["Alexis Mousset "] description = "Simple SMTP client and library" diff --git a/src/client/mod.rs b/src/client/mod.rs index 3985757..0d8f342 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -85,6 +85,13 @@ impl Client { state: TransactionState::new(), } } + + /// Creates a new local SMTP client to port 25 + /// + /// It does not connects to the server, but only create the `Client` + pub fn localhost() -> Client { + Client::new("localhost", Some("localhost")) + } } impl Client { diff --git a/src/lib.rs b/src/lib.rs index 2629ed1..9eff04e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,10 +35,7 @@ //! email.body("Hi, Hello world."); //! email.date(); //! -//! let mut client = Client::new( -//! "localhost", // local server (default port is 25) -//! None, // my hostname (default is localhost) -//! ); +//! let mut client = Client::localhost(); //! let result = client.send_email(email); //! assert!(result.is_ok()); //! ``` @@ -61,10 +58,8 @@ //! email.date(); //! //! let mut client = Client::new( -//! // remote server and custom port -//! ("server.tld", 10025), -//! // my hostname -//! Some("my.hostname.tld"), +//! ("server.tld", 10025), // remote server and custom port +//! Some("my.hostname.tld"), // my hostname //! ); //! let result = client.send_email(email); //! assert!(result.is_ok()); @@ -83,9 +78,9 @@ //! Some("my.hostname.tld"), // my hostname (default is localhost) //! ); //! let result = email_client.send_mail( -//! "user@example.com".to_string(), // sender (reverse-path) +//! "user@example.com".to_string(), // sender (reverse-path) //! vec!("user@example.org".to_string()), // recipient list -//! "Test email", // email content +//! "Test email", // email content //! ); //! assert!(result.is_ok()); //! ```