tfcconnection/src/email.rs

28 lines
793 B
Rust

use color_eyre::Result;
use lettre::{
transport::smtp::authentication::{Credentials, Mechanism},
Message, SmtpTransport, Transport,
};
use tracing::{error, info};
pub async fn send_email(message: Message) -> Result<()> {
let sender = SmtpTransport::relay("mail.tfcconnection.org")
.ok()
.unwrap()
.credentials(Credentials::new(
"no-reply@mail.tfcconnection.org".to_owned(),
"r9f36mNZFtiW4f".to_owned(),
))
.authentication(vec![Mechanism::Plain])
.build();
match sender.send(&message) {
Ok(res) => info!(
"Successfully sent email to server with this response: {:?}",
res
),
Err(e) => error!("There was an error sending the email: {e}"),
}
Ok(())
}