Files
simple-rust-tests/__network/mailsend/src/main.rs
2022-06-06 00:18:09 +08:00

27 lines
656 B
Rust

use mail_send::mail_builder::MessageBuilder;
use mail_send::Transport;
// https://github.com/stalwartlabs/mail-send
#[tokio::main]
async fn main() {
// Build a simple multipart message
let message = MessageBuilder::new()
.from(("John Doe", "john@example.com"))
.to(vec![
("Jane Doe", "jane@example.com"),
])
.subject("Hi!")
.html_body("<h1>Hello, world!</h1>")
.text_body("Hello world!");
// Send the message
Transport::new("unsecured.example.com")
.port(25)
.connect()
.await
.unwrap()
.send(message)
.await
.unwrap();
}