diff --git a/src/email/mod.rs b/src/email/mod.rs index 6f93e60..8be4d23 100644 --- a/src/email/mod.rs +++ b/src/email/mod.rs @@ -165,10 +165,10 @@ impl EmailBuilder { /// Build the Email pub fn build(mut self) -> Result { if self.from.is_none() { - return Err("No from address") + return Err("No from address"); } if self.to.is_empty() { - return Err("No to address") + return Err("No to address"); } if !self.date_issued { diff --git a/src/lib.rs b/src/lib.rs index e4e9f57..2c4aa4c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,18 @@ //! # Rust email client //! -//! This client should tend to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still -//! a work in progress. It is designed to efficiently send emails from an application to a -//! relay email server, as it relies as much as possible on the relay server for sanity and RFC +//! This client should tend to follow [RFC +//! 5321](https://tools.ietf.org/html/rfc5321), but is still +//! a work in progress. It is designed to efficiently send emails from an +//! application to a +//! relay email server, as it relies as much as possible on the relay server +//! for sanity and RFC //! compliance checks. //! //! It implements the following extensions: //! //! * 8BITMIME ([RFC 6152](https://tools.ietf.org/html/rfc6152)) -//! * AUTH ([RFC 4954](http://tools.ietf.org/html/rfc4954)) with PLAIN and CRAM-MD5 mecanisms +//! * AUTH ([RFC 4954](http://tools.ietf.org/html/rfc4954)) with PLAIN and +//! CRAM-MD5 mecanisms //! * STARTTLS ([RFC 2487](http://tools.ietf.org/html/rfc2487)) //! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531)) //! @@ -43,7 +47,8 @@ //! .build().unwrap(); //! //! // Open a local connection on port 25 -//! let mut mailer = Mailer::new(SmtpTransportBuilder::localhost().unwrap().build()); +//! let mut mailer = +//! Mailer::new(SmtpTransportBuilder::localhost().unwrap().build()); //! // Send the email //! let result = mailer.send(email); //! @@ -54,7 +59,8 @@ //! //! ```rust,no_run //! use lettre::email::EmailBuilder; -//! use lettre::transport::smtp::{SecurityLevel, SmtpTransport, SmtpTransportBuilder}; +//! use lettre::transport::smtp::{SecurityLevel, SmtpTransport, +//! SmtpTransportBuilder}; //! use lettre::transport::smtp::authentication::Mecanism; //! use lettre::transport::smtp::SUBMISSION_PORT; //! use lettre::transport::EmailTransport; @@ -74,7 +80,8 @@ //! let email = builder.build().unwrap(); //! //! // Connect to a remote server on a custom port -//! let mut mailer = Mailer::new(SmtpTransportBuilder::new(("server.tld", SUBMISSION_PORT)).unwrap() +//! let mut mailer = Mailer::new(SmtpTransportBuilder::new(("server.tld", +//! SUBMISSION_PORT)).unwrap() //! // Set the name sent during EHLO/HELO, default is `localhost` //! .hello_name("my.hostname.tld") //! // Add credentials for authentication @@ -117,14 +124,16 @@ //! "Hello world !" //! ); //! -//! let mut mailer = Mailer::new(SmtpTransportBuilder::localhost().unwrap().build()); +//! let mut mailer = +//! Mailer::new(SmtpTransportBuilder::localhost().unwrap().build()); //! let result = mailer.send(email); //! assert!(result.is_ok()); //! ``` //! //! ### Lower level //! -//! You can also send commands, here is a simple email transaction without error handling: +//! You can also send commands, here is a simple email transaction without +//! error handling: //! //! ```rust,no_run //! use lettre::transport::smtp::SMTP_PORT; diff --git a/src/transport/error.rs b/src/transport/error.rs index 831b331..ced0e2b 100644 --- a/src/transport/error.rs +++ b/src/transport/error.rs @@ -86,5 +86,5 @@ pub type EmailResult = Result; #[cfg(test)] mod test { - // TODO +// TODO } diff --git a/src/transport/smtp/client/mod.rs b/src/transport/smtp/client/mod.rs index 298ea6f..abb25b2 100644 --- a/src/transport/smtp/client/mod.rs +++ b/src/transport/smtp/client/mod.rs @@ -80,7 +80,6 @@ impl Client { /// Upgrades the underlying connection to SSL/TLS pub fn upgrade_tls_stream(&mut self, ssl_context: &SslContext) -> io::Result<()> { - //let current_stream = self.stream.clone(); if self.stream.is_some() { self.stream.as_mut().unwrap().get_mut().upgrade_tls(ssl_context) } else { diff --git a/src/transport/smtp/mod.rs b/src/transport/smtp/mod.rs index 657ec26..982b615 100644 --- a/src/transport/smtp/mod.rs +++ b/src/transport/smtp/mod.rs @@ -18,7 +18,8 @@ pub mod response; pub mod client; // Registrated port numbers: -// https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml +// https://www.iana. +// org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml /// Default smtp port pub static SMTP_PORT: u16 = 25; @@ -257,7 +258,8 @@ impl EmailTransport for SmtpTransport { } } - // If there is a usable connection, test if the server answers and hello has been sent + // If there is a usable connection, test if the server answers and hello has + // been sent if self.state.connection_reuse_count == 0 { try!(self.client.connect(&self.client_info.server_addr)); @@ -305,13 +307,13 @@ impl EmailTransport for SmtpTransport { // Mail let mail_options = match (self.server_info - .as_ref() - .unwrap() - .supports_feature(&Extension::EightBitMime), - self.server_info - .as_ref() - .unwrap() - .supports_feature(&Extension::EightBitMime)) { + .as_ref() + .unwrap() + .supports_feature(&Extension::EightBitMime), + self.server_info + .as_ref() + .unwrap() + .supports_feature(&Extension::EightBitMime)) { (true, true) => Some("BODY=8BITMIME SMTPUTF8"), (true, false) => Some("BODY=8BITMIME"), (false, _) => None, diff --git a/src/transport/smtp/response.rs b/src/transport/smtp/response.rs index 4d28d35..3b4d046 100644 --- a/src/transport/smtp/response.rs +++ b/src/transport/smtp/response.rs @@ -1,4 +1,5 @@ -//! SMTP response, containing a mandatory return code and an optional text message +//! SMTP response, containing a mandatory return code and an optional text +//! message use std::str::FromStr; use std::fmt::{Display, Formatter, Result};