From 012255537e35118f2330c225ea7c2321a9372b68 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 10 Jan 2024 11:19:41 -0600 Subject: [PATCH] fixing emails formatted wrong --- src/api/health_form.rs | 7 +++++-- src/api/mt_form.rs | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/api/health_form.rs b/src/api/health_form.rs index f6c13ba..9101772 100644 --- a/src/api/health_form.rs +++ b/src/api/health_form.rs @@ -3,7 +3,7 @@ use std::fs; use actix_multipart::form::{tempfile::TempFile, text::Text, MultipartForm}; use actix_web::{post, HttpResponse}; use lettre::{ - message::{header::ContentType, Attachment, MultiPart}, + message::{header::ContentType, Attachment, MultiPart, SinglePart}, transport::smtp::authentication::{Credentials, Mechanism}, Message, SmtpTransport, Transport, }; @@ -459,12 +459,15 @@ pub async fn health_form(MultipartForm(form): MultipartForm) -> Http let content_type = ContentType::parse("image/jpg").unwrap(); let attachment = Attachment::new(filename).body(filebody.unwrap(), content_type); log::info!("{:?}", attachment); - MultiPart::alternative_plain_html(String::from("Testing"), email.to_string()) + MultiPart::mixed() + .singlepart(SinglePart::html(email.to_string())) .singlepart(attachment) } else { MultiPart::alternative_plain_html(String::from("Testing"), email.to_string()) }; + log::info!("{:?}", multi); + if let Ok(m) = Message::builder() .from( "TFC ADMIN " diff --git a/src/api/mt_form.rs b/src/api/mt_form.rs index 48d7bc3..5cafd42 100644 --- a/src/api/mt_form.rs +++ b/src/api/mt_form.rs @@ -3,7 +3,7 @@ use std::fs; use actix_multipart::form::{tempfile::TempFile, text::Text, MultipartForm}; use actix_web::{post, HttpResponse}; use lettre::{ - message::{header::ContentType, Attachment, MultiPart}, + message::{header::ContentType, Attachment, MultiPart, SinglePart}, transport::smtp::authentication::{Credentials, Mechanism}, Message, SmtpTransport, Transport, }; @@ -486,7 +486,6 @@ pub async fn mt_form(MultipartForm(form): MultipartForm) -> HttpResponse let mut path: Option = Some(String::from("")); let mut file_exists = false; let mut filename = String::from(""); - log::info!("{:?}", form); log::info!("{:?}", file_exists); if let Some(f) = form.file { if let Some(file) = f.file_name { @@ -515,7 +514,8 @@ pub async fn mt_form(MultipartForm(form): MultipartForm) -> HttpResponse let content_type = ContentType::parse("image/jpg").unwrap(); let attachment = Attachment::new(filename).body(filebody.unwrap(), content_type); log::info!("{:?}", attachment); - MultiPart::alternative_plain_html(String::from("Testing"), email.to_string()) + MultiPart::mixed() + .singlepart(SinglePart::html(email.to_string())) .singlepart(attachment) } else { MultiPart::alternative_plain_html(String::from("Testing"), email.to_string())