#[cfg(test)] #[cfg(all(feature = "smtp-transport", feature = "builder"))] mod sync { use lettre::{Message, SmtpTransport, Transport}; #[test] fn smtp_transport_simple() { let email = Message::builder() .from("NoBody ".parse().unwrap()) .reply_to("Yuin ".parse().unwrap()) .to("Hei ".parse().unwrap()) .subject("Happy new year") .body(String::from("Be happy!")) .unwrap(); let sender = SmtpTransport::builder_dangerous("127.0.0.1") .port(2525) .build(); sender.send(&email).unwrap(); } } #[cfg(test)] #[cfg(all(feature = "smtp-transport", feature = "builder", feature = "tokio1"))] mod tokio_1 { use lettre::{AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor}; use tokio1_crate as tokio; #[tokio::test] async fn smtp_transport_simple_tokio1() { let email = Message::builder() .from("NoBody ".parse().unwrap()) .reply_to("Yuin ".parse().unwrap()) .to("Hei ".parse().unwrap()) .subject("Happy new year") .body(String::from("Be happy!")) .unwrap(); let sender: AsyncSmtpTransport = AsyncSmtpTransport::::builder_dangerous("127.0.0.1") .port(2525) .build(); sender.send(email).await.unwrap(); } } #[cfg(test)] #[cfg(all( feature = "smtp-transport", feature = "builder", feature = "async-std1" ))] mod asyncstd_1 { use lettre::{AsyncSmtpTransport, AsyncStd1Executor, AsyncTransport, Message}; #[async_std::test] async fn smtp_transport_simple_asyncstd1() { let email = Message::builder() .from("NoBody ".parse().unwrap()) .reply_to("Yuin ".parse().unwrap()) .to("Hei ".parse().unwrap()) .subject("Happy new year") .body(String::from("Be happy!")) .unwrap(); let sender: AsyncSmtpTransport = AsyncSmtpTransport::::builder_dangerous("127.0.0.1") .port(2525) .build(); sender.send(email).await.unwrap(); } }