Simple Send Email Client in Rust
This library provides a simple api to send email via SMTP. This api is largely a wrapper for lettre crate.
Quick Start
To send a email, provide two structs Sender, Email, and a vector of recipient to send_email function:
use send_email::*;
fn main() {
let sender = Sender::new(
"example@gmail.com", "PASSWORD", "Eric Elon", SmtpServer::Gmail, "example@gmail.com", );
let message = EmailContent::new(
"Hi", "Hello, this is a test email.", false, vec!["pic.jpg", "Cargo.toml"], );
let recipients = vec![
Recipient::new(
"Esther Frank", "example@gmail.com", Category::To, ),
Recipient::new(
"", "example@outlook.com",
Category::Cc, ),
];
send_email(&sender, &message, &recipients).unwrap();
}
Password can be stored in toml file and the program can read from it securely:
let sender = Sender::new_passwd_from_file(
"example.com", ".password.toml", "Francis Waverley", SmtpServer::Gmail, );
password = "PASSWORD"
Sending an email is easy as this.