From 58b498b9deee49c58a44bb0ece5580f2527efbba Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 15 Feb 2024 22:21:40 +0100 Subject: [PATCH] use proper encoding --- src/model/mail.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/model/mail.rs b/src/model/mail.rs index 098723e..6df129c 100644 --- a/src/model/mail.rs +++ b/src/model/mail.rs @@ -1,10 +1,7 @@ use std::{error::Error, fs}; use lettre::{ - message::{ - header::{self, ContentType}, - Attachment, MultiPart, SinglePart, - }, + message::{header::ContentType, Attachment, MultiPart, SinglePart}, transport::smtp::authentication::Credentials, Message, SmtpTransport, Transport, }; @@ -49,11 +46,7 @@ impl Mail { } } - let mut multipart = MultiPart::mixed().singlepart( - SinglePart::builder() - .header(header::ContentType::TEXT_HTML) - .body(String::from(data.body)), - ); + let mut multipart = MultiPart::mixed().singlepart(SinglePart::plain(data.body)); for temp_file in &data.files { let content = fs::read(temp_file.path().unwrap()).unwrap(); @@ -69,11 +62,7 @@ impl Mail { multipart = multipart.singlepart(attachment); } - let email = email - .subject(data.subject) - .header(ContentType::TEXT_PLAIN) - .multipart(multipart) - .unwrap(); + let email = email.subject(data.subject).multipart(multipart).unwrap(); let creds = Credentials::new("no-reply@rudernlinz.at".to_owned(), smtp_pw);