Low level commands example
This commit is contained in:
@@ -292,7 +292,7 @@ impl<S: Connecter + Write + Read = TcpStream> Client<S> {
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
||||
20
src/lib.rs
20
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<TcpStream> = 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)]
|
||||
|
||||
Reference in New Issue
Block a user