This commit is contained in:
Alexis Mousset
2014-05-06 08:37:41 +02:00
parent 83ffa36c1e
commit 14497e7e1d
4 changed files with 27 additions and 9 deletions

View File

@@ -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)

View File

@@ -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<StrBuf, TcpStream> = 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<StrBuf, TcpStream> =
SmtpClient::new(StrBuf::from_str(server), from_str::<Port>(port), None);
email_client.send_mail(
StrBuf::from_str(source_address),
vec!(StrBuf::from_str(recipient_address)),
StrBuf::from_str(message)
);
}

View File

@@ -262,7 +262,7 @@ impl SmtpClient<StrBuf, TcpStream> {
_ => {}
}
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.

View File

@@ -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=<kelvin.moutet@gmail.com>, orig_to=<kelvin@minet.net>, 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"]