use lettre::{ message::{header, MultiPart, SinglePart}, Message, SmtpTransport, Transport, }; fn main() { // The html we want to send. let html = r#" Hello from Lettre!

Hello from Lettre!

A mailer library for Rust

"#; // Build the message. let email = Message::builder() .from("NoBody ".parse().unwrap()) .to("Hei ".parse().unwrap()) .subject("Hello from Lettre!") .multipart( MultiPart::alternative() // This is composed of two parts. .singlepart( SinglePart::builder() .header(header::ContentType::TEXT_PLAIN) .body(String::from("Hello from Lettre! A mailer library for Rust")), // Every message should have a plain text fallback. ) .singlepart( SinglePart::builder() .header(header::ContentType::TEXT_HTML) .body(String::from(html)), ), ) .expect("failed to build email"); let mailer = SmtpTransport::builder_dangerous("localhost") .port(7778) .build(); // Store the message when you're ready. mailer.send(&email).expect("failed to deliver message"); }