From: Paolo Barbolini Date: Sun, 8 May 2022 17:00:12 +0000 (+0200) Subject: Simplify building plain/html emails (#2251) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/save/%24%7BgetStaticDir%28%29%7D/js/readmes/README.ja.md?a=commitdiff_plain;h=559e43075a76d5d92c1085eaeed0a3d5f8033abe;p=lemmy.git Simplify building plain/html emails (#2251) --- diff --git a/crates/utils/src/email.rs b/crates/utils/src/email.rs index b1d58c7e..13aff698 100644 --- a/crates/utils/src/email.rs +++ b/crates/utils/src/email.rs @@ -1,7 +1,7 @@ use crate::{settings::structs::Settings, LemmyError}; use html2text; use lettre::{ - message::{header, Mailbox, MultiPart, SinglePart}, + message::{Mailbox, MultiPart}, transport::smtp::{authentication::Credentials, extension::ClientId}, Address, Message, @@ -60,23 +60,10 @@ pub fn send_email( )) .message_id(Some(format!("{}@{}", Uuid::new_v4(), settings.hostname))) .subject(subject) - .multipart( - MultiPart::mixed().multipart( - MultiPart::alternative() - .singlepart( - SinglePart::builder() - .header(header::ContentType::TEXT_PLAIN) - .body(plain_text), - ) - .multipart( - MultiPart::related().singlepart( - SinglePart::builder() - .header(header::ContentType::TEXT_HTML) - .body(html.to_string()), - ), - ), - ), - ) + .multipart(MultiPart::alternative_plain_html( + plain_text, + html.to_string(), + )) .expect("email built incorrectly"); // don't worry about 'dangeous'. it's just that leaving it at the default configuration