diff --git a/Cargo.toml b/Cargo.toml index d5cd29f..e292dc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ async-std = { version = "1.5", optional = true, features = ["unstable"] } async-trait = { version = "0.1", optional = true } tokio02_crate = { package = "tokio", version = "0.2.7", features = ["fs", "process", "io-util"], optional = true } base64 = { version = "0.12", optional = true } -bufstream = { version = "0.1", optional = true } hostname = { version = "0.3", optional = true } hyperx = { version = "1", optional = true, features = ["headers"] } idna = "0.2" @@ -61,7 +60,7 @@ default = ["file-transport", "smtp-transport", "native-tls", "hostname", "r2d2", file-transport = ["serde", "serde_json"] rustls-tls = ["webpki", "webpki-roots", "rustls"] sendmail-transport = [] -smtp-transport = ["bufstream", "base64", "nom"] +smtp-transport = ["base64", "nom"] unstable = [] [package.metadata.docs.rs] diff --git a/src/transport/smtp/client/mod.rs b/src/transport/smtp/client/mod.rs index 63b2931..5d3df29 100644 --- a/src/transport/smtp/client/mod.rs +++ b/src/transport/smtp/client/mod.rs @@ -11,14 +11,13 @@ use crate::{ }, Envelope, }; -use bufstream::BufStream; #[cfg(feature = "log")] use log::debug; #[cfg(feature = "serde")] use std::fmt::Debug; use std::{ fmt::Display, - io::{self, BufRead, Write}, + io::{self, BufRead, BufReader, Write}, net::ToSocketAddrs, string::String, time::Duration, @@ -99,7 +98,7 @@ macro_rules! try_smtp ( pub struct SmtpConnection { /// TCP stream between client and server /// Value is None before connection - stream: BufStream, + stream: BufReader, /// Panic state panic: bool, /// Information about the server @@ -122,7 +121,7 @@ impl SmtpConnection { hello_name: &ClientId, tls_parameters: Option<&TlsParameters>, ) -> Result { - let stream = BufStream::new(NetworkStream::connect(server, timeout, tls_parameters)?); + let stream = BufReader::new(NetworkStream::connect(server, timeout, tls_parameters)?); let mut conn = SmtpConnection { stream, panic: false, @@ -170,8 +169,7 @@ impl SmtpConnection { } pub fn can_starttls(&self) -> bool { - !self.stream.get_ref().is_encrypted() - && self.server_info.supports_feature(Extension::StartTls) + !self.is_encrypted() && self.server_info.supports_feature(Extension::StartTls) } #[allow(unused_variables)] @@ -224,7 +222,7 @@ impl SmtpConnection { /// Sets the underlying stream pub fn set_stream(&mut self, stream: NetworkStream) { - self.stream = BufStream::new(stream); + self.stream = BufReader::new(stream); } /// Tells if the underlying stream is currently encrypted @@ -299,8 +297,8 @@ impl SmtpConnection { /// Writes a string to the server fn write(&mut self, string: &[u8]) -> Result<(), Error> { - self.stream.write_all(string)?; - self.stream.flush()?; + self.stream.get_mut().write_all(string)?; + self.stream.get_mut().flush()?; #[cfg(feature = "log")] debug!(