Fix doctests (#906)

This commit is contained in:
Paolo Barbolini
2023-10-15 16:04:12 +02:00
committed by GitHub
parent 74117d5cc6
commit 20c3701eb0
2 changed files with 21 additions and 5 deletions

View File

@@ -215,9 +215,12 @@ where
/// ```rust,no_run
/// use lettre::{
/// message::header::ContentType, transport::smtp::authentication::Credentials,
/// AsyncSmtpTransport, Message, Transport,
/// AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor,
/// };
/// # use tokio1_crate as tokio;
///
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let email = Message::builder()
/// .from("NoBody <nobody@domain.tld>".parse().unwrap())
/// .reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
@@ -228,15 +231,20 @@ where
/// .unwrap();
///
/// // Open a remote connection to gmail
/// let mailer = AsyncSmtpTransport::from_url("smtps://username:password@smtp.example.com:465")
/// let mailer: AsyncSmtpTransport<Tokio1Executor> =
/// AsyncSmtpTransport::<Tokio1Executor>::from_url(
/// "smtps://username:password@smtp.example.com:465",
/// )
/// .unwrap()
/// .build();
///
/// // Send the email
/// match mailer.send(&email).await {
/// match mailer.send(email).await {
/// Ok(_) => println!("Email sent successfully!"),
/// Err(e) => panic!("Could not send email: {e:?}"),
/// }
/// # Ok(())
/// # }
/// ```
#[cfg(any(feature = "native-tls", feature = "rustls-tls", feature = "boring-tls"))]
#[cfg_attr(

View File

@@ -73,15 +73,23 @@ impl AsyncSmtpConnection {
/// # Example
///
/// ```no_run
/// # use std::time::Duration;
/// # use lettre::transport::smtp::{client::{AsyncSmtpConnection, TlsParameters}, extension::ClientId};
/// # use tokio1_crate::{self as tokio, net::ToSocketAddrs as _};
/// #
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let connection = AsyncSmtpConnection::connect_tokio1(
/// ("example.com", 465),
/// Some(Duration::from_secs(60)),
/// &ClientId::default(),
/// Some(TlsParameters::new("example.com")?),
/// Some(TlsParameters::new("example.com".to_owned())?),
/// None,
/// )
/// .await
/// .unwrap()
/// .unwrap();
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "tokio1")]
pub async fn connect_tokio1<T: tokio1_crate::net::ToSocketAddrs>(