pub struct AsyncSmtpConnection { /* private fields */ }
smtp-transport
only.Expand description
Structure that implements the SMTP client
Implementations§
source§impl AsyncSmtpConnection
impl AsyncSmtpConnection
sourcepub fn server_info(&self) -> &ServerInfo
pub fn server_info(&self) -> &ServerInfo
Get information about the server
sourcepub async fn connect_with_transport(
stream: Box<dyn AsyncTokioStream>,
hello_name: &ClientId
) -> Result<AsyncSmtpConnection, Error>
pub async fn connect_with_transport( stream: Box<dyn AsyncTokioStream>, hello_name: &ClientId ) -> Result<AsyncSmtpConnection, Error>
Connects with existing async stream
Sends EHLO and parses server information
sourcepub async fn connect_tokio1<T: ToSocketAddrs>(
server: T,
timeout: Option<Duration>,
hello_name: &ClientId,
tls_parameters: Option<TlsParameters>,
local_address: Option<IpAddr>
) -> Result<AsyncSmtpConnection, Error>
pub async fn connect_tokio1<T: ToSocketAddrs>( server: T, timeout: Option<Duration>, hello_name: &ClientId, tls_parameters: Option<TlsParameters>, local_address: Option<IpAddr> ) -> Result<AsyncSmtpConnection, Error>
Connects to the configured server
If tls_parameters
is Some
, then the connection will use Implicit TLS (sometimes
referred to as SMTPS
). See also AsyncSmtpConnection::starttls
.
If local_address
is Some
, then the address provided shall be used to bind the
connection to a specific local address using tokio1_crate::net::TcpSocket::bind
.
Sends EHLO and parses server information
§Example
let connection = AsyncSmtpConnection::connect_tokio1(
("example.com", 465),
Some(Duration::from_secs(60)),
&ClientId::default(),
Some(TlsParameters::new("example.com".to_owned())?),
None,
)
.await
.unwrap();
sourcepub async fn connect_asyncstd1<T: ToSocketAddrs>(
server: T,
timeout: Option<Duration>,
hello_name: &ClientId,
tls_parameters: Option<TlsParameters>
) -> Result<AsyncSmtpConnection, Error>
pub async fn connect_asyncstd1<T: ToSocketAddrs>( server: T, timeout: Option<Duration>, hello_name: &ClientId, tls_parameters: Option<TlsParameters> ) -> Result<AsyncSmtpConnection, Error>
Connects to the configured server
Sends EHLO and parses server information
pub async fn send( &mut self, envelope: &Envelope, email: &[u8] ) -> Result<Response, Error>
pub fn has_broken(&self) -> bool
pub fn can_starttls(&self) -> bool
sourcepub async fn starttls(
&mut self,
tls_parameters: TlsParameters,
hello_name: &ClientId
) -> Result<(), Error>
pub async fn starttls( &mut self, tls_parameters: TlsParameters, hello_name: &ClientId ) -> Result<(), Error>
pub async fn quit(&mut self) -> Result<Response, Error>
pub async fn abort(&mut self)
sourcepub fn set_stream(&mut self, stream: AsyncNetworkStream)
pub fn set_stream(&mut self, stream: AsyncNetworkStream)
Sets the underlying stream
sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Tells if the underlying stream is currently encrypted
sourcepub async fn test_connected(&mut self) -> bool
pub async fn test_connected(&mut self) -> bool
Checks if the server is connected using the NOOP SMTP command
sourcepub async fn auth(
&mut self,
mechanisms: &[Mechanism],
credentials: &Credentials
) -> Result<Response, Error>
pub async fn auth( &mut self, mechanisms: &[Mechanism], credentials: &Credentials ) -> Result<Response, Error>
Sends an AUTH command with the given mechanism, and handles the challenge if needed
sourcepub async fn message(&mut self, message: &[u8]) -> Result<Response, Error>
pub async fn message(&mut self, message: &[u8]) -> Result<Response, Error>
Sends the message content
sourcepub async fn command<C: Display>(
&mut self,
command: C
) -> Result<Response, Error>
pub async fn command<C: Display>( &mut self, command: C ) -> Result<Response, Error>
Sends an SMTP command
sourcepub async fn read_response(&mut self) -> Result<Response, Error>
pub async fn read_response(&mut self) -> Result<Response, Error>
Gets the SMTP response