27 lines
656 B
Rust
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();
|
|
}
|