use lettre::error::Error as EmailError; use lettre::message::Mailbox; use lettre::transport::stub::StubTransport; use lettre::{Address, AsyncTransport, Message}; pub async fn send_registration_email(address: Address) -> Result<(), EmailError> { let message = Message::builder() .from(Mailbox::new( Some("Some username".to_string()), "foo@example.com".parse().unwrap(), )) .to(Mailbox::new(None, address)) .subject("Registration for this website") .body("hell world".to_string()) .unwrap(); StubTransport::new_ok().send(message).await.unwrap(); Ok(()) }