making email a lot smarter

This commit is contained in:
Chris Cochrun 2024-11-08 07:07:10 -06:00
parent a777d0a29e
commit e8dbb324f3
4 changed files with 253 additions and 437 deletions

View file

@ -11,6 +11,8 @@ use maud::html;
use maud::DOCTYPE;
use reqwest::{Client, Error};
use crate::email::send_email;
#[derive(Debug, MultipartForm, Default)]
struct CampForm {
#[multipart(rename = "first-name")]
@ -258,22 +260,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
.subject(email_subject)
.multipart(multi)
{
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(&m) {
Ok(res) => log::info!(
"Successfully sent email to server with this response: {:?}",
res
),
Err(e) => log::error!("{e}"),
}
let _ = send_email(m);
} else {
log::info!("Email incorrect");
}