diff --git a/examples/smtp.rs b/examples/smtp.rs deleted file mode 100644 index f700488..0000000 --- a/examples/smtp.rs +++ /dev/null @@ -1,30 +0,0 @@ -extern crate lettre; - -use lettre::email::EmailBuilder; -use lettre::transport::EmailTransport; -use lettre::transport::smtp::SmtpTransportBuilder; - -fn main() { - let email = EmailBuilder::new() - // Addresses can be specified by the tuple (email, alias) - .to(("user@example.org", "Firstname Lastname")) - // ... or by an address only - .from("user@example.com") - .subject("Hi, Hello world") - .text("Hello world.") - .build() - .unwrap(); - - // Open a local connection on port 25 - let mut mailer = SmtpTransportBuilder::localhost().unwrap().build(); - // Send the email - let result = mailer.send(email); - - if result.is_ok() { - println!("Email sent"); - } else { - println!("Could not send email: {:?}", result); - } - - assert!(result.is_ok()); -} diff --git a/lettre/src/smtp/client/mod.rs b/lettre/src/smtp/client/mod.rs index 8f35746..2305e0e 100644 --- a/lettre/src/smtp/client/mod.rs +++ b/lettre/src/smtp/client/mod.rs @@ -133,6 +133,7 @@ impl Client { } /// Checks if the server is connected using the NOOP SMTP command + #[cfg_attr(feature = "cargo-clippy", allow(wrong_self_convention))] pub fn is_connected(&mut self) -> bool { self.noop().is_ok() } diff --git a/lettre/src/smtp/client/net.rs b/lettre/src/smtp/client/net.rs index 82883b4..244fb32 100644 --- a/lettre/src/smtp/client/net.rs +++ b/lettre/src/smtp/client/net.rs @@ -27,7 +27,7 @@ impl Connector for NetworkStream { match Ssl::new(context) { Ok(ssl) => { ssl.connect(tcp_stream) - .map(|s| NetworkStream::Ssl(s)) + .map(NetworkStream::Ssl) .map_err(|e| io::Error::new(ErrorKind::Other, e)) } Err(e) => Err(io::Error::new(ErrorKind::Other, e)), diff --git a/lettre/src/smtp/extension.rs b/lettre/src/smtp/extension.rs index 6a279e4..e65acc0 100644 --- a/lettre/src/smtp/extension.rs +++ b/lettre/src/smtp/extension.rs @@ -53,10 +53,14 @@ pub struct ServerInfo { impl Display for ServerInfo { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "{} with {}", self.name, match self.features.is_empty() { - true => "no supported features".to_string(), - false => format!("{:?}", self.features), - }) + write!(f, + "{} with {}", + self.name, + if self.features.is_empty() { + "no supported features".to_string() + } else { + format!("{:?}", self.features) + }) } } diff --git a/lettre/src/smtp/mod.rs b/lettre/src/smtp/mod.rs index 5f577db..953ab13 100644 --- a/lettre/src/smtp/mod.rs +++ b/lettre/src/smtp/mod.rs @@ -286,6 +286,7 @@ impl SmtpTransport { impl EmailTransport for SmtpTransport { /// Sends an email + #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms, cyclomatic_complexity))] fn send(&mut self, email: T) -> SmtpResult { // Extract email information @@ -299,8 +300,8 @@ impl EmailTransport for SmtpTransport { if self.state.connection_reuse_count == 0 { try!(self.client .connect(&self.client_info.server_addr, - match &self.client_info.security_level { - &SecurityLevel::EncryptedWrapper => { + match self.client_info.security_level { + SecurityLevel::EncryptedWrapper => { Some(&self.client_info.ssl_context) } _ => None, @@ -396,7 +397,7 @@ impl EmailTransport for SmtpTransport { // Recipient for to_address in &email.to() { - try_smtp!(self.client.rcpt(&to_address), self); + try_smtp!(self.client.rcpt(to_address), self); // Log the rcpt command info!("{}: to=<{}>", message_id, to_address); } diff --git a/lettre_email/examples/smtp.rs b/lettre_email/examples/smtp.rs index 6625189..6c1aca2 100644 --- a/lettre_email/examples/smtp.rs +++ b/lettre_email/examples/smtp.rs @@ -1,9 +1,9 @@ extern crate lettre; extern crate lettre_email; -use lettre_email::email::EmailBuilder; use lettre::EmailTransport; use lettre::smtp::SmtpTransportBuilder; +use lettre_email::email::EmailBuilder; fn main() { let email = EmailBuilder::new() diff --git a/lettre_email/src/email.rs b/lettre_email/src/email.rs index b3ab358..56291c6 100644 --- a/lettre_email/src/email.rs +++ b/lettre_email/src/email.rs @@ -1,13 +1,13 @@ //! Simple email representation -use error::Error; use email_format::{Address, Header, Mailbox, MimeMessage, MimeMultipartType}; +use error::Error; +use lettre::SendableEmail; use mime::Mime; use std::fmt; use std::fmt::{Display, Formatter}; use time::{Tm, now}; use uuid::Uuid; -use lettre::SendableEmail; /// Converts an address or an address with an alias to a `Header` pub trait IntoHeader { @@ -776,9 +776,9 @@ pub trait ExtractableEmail { #[cfg(test)] mod test { - use lettre::SendableEmail; use super::{Email, EmailBuilder, Envelope, IntoEmail, SimpleEmail}; use email_format::{Header, MimeMessage}; + use lettre::SendableEmail; use time::now; use uuid::Uuid;