diff --git a/Makefile b/Makefile index c6baa87..fa9039e 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ $(libsmtp): $(smtp_files) mkdir -p $(BUILDDIR) $(RUSTC) $(RUSTFLAGS) $(SMTP_LIB) --out-dir=$(BUILDDIR) -all: smtp examples doc +all: smtp doc doc: $(smtp_files) $(RUSTDOC) $(SMTP_LIB) diff --git a/src/examples/client.rs b/src/examples/client.rs index 5193d01..6103f22 100644 --- a/src/examples/client.rs +++ b/src/examples/client.rs @@ -11,10 +11,31 @@ extern crate smtp; use std::io::net::tcp::TcpStream; -use smtp::client::SmtpClient; use std::strbuf::StrBuf; +use std::io::net::ip::Port; +use std::os; +use smtp::client::SmtpClient; fn main() { - let mut email_client: SmtpClient = SmtpClient::new(StrBuf::from_str("localhost"), None, None); - email_client.send_mail(StrBuf::from_str("user@localhost"), vec!(StrBuf::from_str("user@localhost")), StrBuf::from_str("Test email")); + //! For now, only one word messages + //! + //! TODO: use parameters, flexible syntax + let args = os::args(); + match args.len() { + 6 => sendmail(args[1], args[2], args[3], args[4], args[5]), + _ => { + println!("Usage: {} source_address recipient_address message server port", args[0]); + return; + }, + }; +} + +fn sendmail(source_address: &str, recipient_address: &str, message: &str, server: &str, port: &str) { + let mut email_client: SmtpClient = + SmtpClient::new(StrBuf::from_str(server), from_str::(port), None); + email_client.send_mail( + StrBuf::from_str(source_address), + vec!(StrBuf::from_str(recipient_address)), + StrBuf::from_str(message) + ); } diff --git a/src/smtp/client.rs b/src/smtp/client.rs index 7297d55..b1d078a 100644 --- a/src/smtp/client.rs +++ b/src/smtp/client.rs @@ -262,7 +262,7 @@ impl SmtpClient { _ => {} } - info!("SMTP server: {:s}", self.server_info.clone().unwrap().to_str()); + debug!("Server {:s}", self.server_info.clone().unwrap().to_str()); // Checks message encoding according to the server's capability // TODO : Add an encoding check. diff --git a/src/smtp/lib.rs b/src/smtp/lib.rs index b8ca895..454bc99 100644 --- a/src/smtp/lib.rs +++ b/src/smtp/lib.rs @@ -42,13 +42,10 @@ //! ); //! ``` -// May 4 21:48:18 mx1 smtp-gmail/smtp[12657]: Untrusted TLS connection established to gmail-smtp-in.l.google.com[173.194.66.26]:25: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits) -// May 4 21:48:18 mx1 smtp-gmail/smtp[12657]: 69800746A7B: to=, orig_to=, relay=gmail-smtp-in.l.google.com[173.194.66.26]:25, delay=2.6, delays=1.7/0.03/0.19/0.61, dsn=2.0.0, status=sent (250 2.0.0 OK 1399232898 fy10si2284441wib.22 - gsmtp) - #![crate_id = "smtp#0.1-pre"] #![desc = "Rust SMTP client"] -#![comment = "Simple SMTP client, without AUTH or SSL/TLS for now"] +#![comment = "Simple SMTP client"] #![license = "MIT/ASL2"] #![crate_type = "lib"]