From 3105a0373b8754f37b326239c1cf7129fae06e1b Mon Sep 17 00:00:00 2001 From: Andrei Zisu Date: Mon, 2 Oct 2023 21:48:15 +0200 Subject: [PATCH] Add quit command Signed-off-by: Andrei Zisu --- melib/src/smtp.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/melib/src/smtp.rs b/melib/src/smtp.rs index 3639f270..641d45e8 100644 --- a/melib/src/smtp.rs +++ b/melib/src/smtp.rs @@ -70,6 +70,7 @@ //! Address::try_from("foo-chat@example.com").unwrap(), //! ]), //! )).unwrap(); +//! futures::executor::block_on(conn.quit()).unwrap(); //! Ok(()) //! ``` @@ -807,6 +808,12 @@ impl SmtpConnection { } Ok(()) } + + pub async fn quit(&mut self) -> Result<()> { + self.send_command(&[b"QUIT"]).await?; + + Ok(()) + } } /// Expected reply code in a single or multi-line reply by the server @@ -1317,6 +1324,7 @@ mod test { ]), )) .unwrap(); + futures::executor::block_on(connection.quit()).unwrap(); assert_eq!(handler.stored.lock().unwrap().len(), 2); } }