Skip to main content

14_mail/
14_mail.rs

1use flyer::{mail::Mail, server};
2use uuid::Uuid;
3
4fn main() {
5    let server = server("127.0.0.1", 9999)
6        .mailer("127.0.0.1".to_string(), 5555, "".to_string(), "".to_string(), false);
7    
8    server.router().get("/send-mail", async |_req, res| {
9        // Send to single email
10        Mail::new()
11            .from("no-reply@test.com".to_string(), Some("no-reply"))
12            .html(format!("<h1>Token: {}</h1>", Uuid::new_v4()))
13            .send("user@test.com".to_string(), Some("User"))
14            .unwrap();
15
16        return res.html("<h1>Email sent!</h1>")
17    });
18
19    print!("\r\n\r\nRunning server: {}\r\n\r\n", server.address());
20
21    server.listen();
22}