diff --git a/examples/client.rs b/examples/client.rs index 4339443..7619c6a 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -12,25 +12,48 @@ extern crate log; extern crate env_logger; extern crate smtp; +use std::sync::{Arc, Mutex}; +use std::collections::HashSet; +use std::thread; + use smtp::sender::{Sender, SenderBuilder}; use smtp::email::EmailBuilder; fn main() { env_logger::init().unwrap(); - let email = EmailBuilder::new() + let mut sender = Arc::new(Mutex::new(SenderBuilder::localhost().hello_name("localhost") + .enable_connection_reuse(true).build())); + + let mut threads = Vec::new(); + for _ in 1..5 { + + let th_sender = sender.clone(); + threads.push(thread::spawn(move || { + println!("thpouet"); + let email = EmailBuilder::new() .to("user@localhost") .from("user@localhost") .body("Hello World!") .subject("Hello") .build(); - - let mut sender: Sender = SenderBuilder::localhost().hello_name("localhost") - .enable_connection_reuse(true).build(); - - for _ in (1..5) { - let _ = sender.send(email.clone()); + + let _ = th_sender.lock().unwrap().send(email); + })); } + + for thread in threads { + let _ = thread.join(); + } + + let email = EmailBuilder::new() + .to("user@localhost") + .from("user@localhost") + .body("Hello World!") + .subject("Hello Bis") + .build(); + + let mut sender = sender.lock().unwrap(); let result = sender.send(email); sender.close(); diff --git a/src/authentication.rs b/src/authentication.rs index c7a4326..e86906b 100644 --- a/src/authentication.rs +++ b/src/authentication.rs @@ -21,7 +21,7 @@ use crypto::mac::Mac; use NUL; use error::Error; -/// TODO +/// Represents authentication mecanisms #[derive(PartialEq,Eq,Copy,Clone,Hash,Debug)] pub enum Mecanism { /// PLAIN authentication mecanism @@ -44,7 +44,7 @@ impl Display for Mecanism { } impl Mecanism { - /// TODO + /// Does the mecanism supports initial response pub fn supports_initial_response(&self) -> bool { match *self { Mecanism::Plain => true, @@ -52,7 +52,7 @@ impl Mecanism { } } - /// TODO + /// Returns the string to send to the server, using the provided username, password and challenge in some cases pub fn response(&self, username: &str, password: &str, challenge: Option<&str>) -> Result { match *self { Mecanism::Plain => {