fixing emails formatted wrong

This commit is contained in:
Chris Cochrun 2024-01-10 11:19:41 -06:00
parent 64917db638
commit 012255537e
2 changed files with 8 additions and 5 deletions

View file

@ -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<HealthForm>) -> 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 <no-reply@mail.tfcconnection.org>"

View file

@ -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<MtForm>) -> HttpResponse
let mut path: Option<String> = 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<MtForm>) -> 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())