pub fn connection(&self) -> Result<SmtpConnection, Error> {
        #[allow(clippy::match_single_binding)]
        let tls_parameters = match self.info.tls {
            #[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
            Tls::Wrapper(ref tls_parameters) => Some(tls_parameters),
            _ => None,
        };

        #[allow(unused_mut)]
        let mut conn = SmtpConnection::connect::<(&str, u16)>(
            (self.info.server.as_ref(), self.info.port),
            self.info.timeout,
            &self.info.hello_name,
            tls_parameters,
        )?;

        #[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
        match self.info.tls {
            Tls::Opportunistic(ref tls_parameters) => {
                if conn.can_starttls() {
                    conn.starttls(tls_parameters, &self.info.hello_name)?;
                }
            }
            Tls::Required(ref tls_parameters) => {
                conn.starttls(tls_parameters, &self.info.hello_name)?;
            }
            _ => (),
        }

        if let Some(credentials) = &self.info.credentials {
            conn.auth(&self.info.authentication, &credentials)?;
        }
        Ok(conn)
    }
/// Creates a new connection directly usable to send emails
///
/// Handles encryption and authentication
Creates a new connection directly usable to send emails
Handles encryption and authentication
Creates a new connection directly usable to send emails Handles encryption and authentication
pub fn connection(&self) -> Result<SmtpConnection, Error> {
        #[allow(clippy::match_single_binding)]
        let tls_parameters = match self.info.tls {
            #[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
            Tls::Wrapper(ref tls_parameters) => Some(tls_parameters),
            _ => None,
        };
        #[allow(unused_mut)]
        let mut conn = SmtpConnection::connect::<(&str, u16)>(
            (self.info.server.as_ref(), self.info.port),
            self.info.timeout,
            &self.info.hello_name,
            tls_parameters,
        )?;
        #[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
        match self.info.tls {
            Tls::Opportunistic(ref tls_parameters) => {
                if conn.can_starttls() {
                    conn.starttls(tls_parameters, &self.info.hello_name)?;
                }
            }
            Tls::Required(ref tls_parameters) => {
                conn.starttls(tls_parameters, &self.info.hello_name)?;
            }
            _ => (),
        }
        if let Some(credentials) = &self.info.credentials {
            conn.auth(&self.info.authentication, &credentials)?;
        }
        Ok(conn)
    }
pub fn connection ( & self ) -> Result < SmtpConnection , Error > { # [ allow ( clippy match_single_binding ) ] let tls_parameters = match self . info . tls { # [ cfg ( any ( feature " " feature " " ) ) ] Tls :: Wrapper ( ref tls_parameters ) => Some ( tls_parameters ) , _ => None , } ; # [ allow ( unused_mut ) ] let mut conn = SmtpConnection :: connect :: < ( & str , u16 ) > ( ( self . info . server . as_ref ( ) , self . info . port ) , self . info . timeout , & self . info . hello_name , tls_parameters , ) ? ; # [ cfg ( any ( feature " " feature " " ) ) ] match self . info . tls { Tls :: Opportunistic ( ref tls_parameters ) => { if conn . can_starttls ( ) { conn . starttls ( tls_parameters , & self . info . hello_name ) ? ; } } Tls :: Required ( ref tls_parameters ) => { conn . starttls ( tls_parameters , & self . info . hello_name ) ? ; } _ => ( ) , } if let Some ( credentials ) = & self . info . credentials { conn . auth ( & self . info . authentication , & credentials ) ? ; } Ok ( conn ) }
Creates a new connection directly usable to send emails
Handles encryption and authentication
Creates a new connection directly usable to send emails Handles encryption and authentication
&self
&self