Simplify building plain/html emails (#2251)
This commit is contained in:
parent
7b86441bab
commit
559e43075a
1 changed files with 5 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
use crate::{settings::structs::Settings, LemmyError};
|
use crate::{settings::structs::Settings, LemmyError};
|
||||||
use html2text;
|
use html2text;
|
||||||
use lettre::{
|
use lettre::{
|
||||||
message::{header, Mailbox, MultiPart, SinglePart},
|
message::{Mailbox, MultiPart},
|
||||||
transport::smtp::{authentication::Credentials, extension::ClientId},
|
transport::smtp::{authentication::Credentials, extension::ClientId},
|
||||||
Address,
|
Address,
|
||||||
Message,
|
Message,
|
||||||
|
@ -60,23 +60,10 @@ pub fn send_email(
|
||||||
))
|
))
|
||||||
.message_id(Some(format!("{}@{}", Uuid::new_v4(), settings.hostname)))
|
.message_id(Some(format!("{}@{}", Uuid::new_v4(), settings.hostname)))
|
||||||
.subject(subject)
|
.subject(subject)
|
||||||
.multipart(
|
.multipart(MultiPart::alternative_plain_html(
|
||||||
MultiPart::mixed().multipart(
|
plain_text,
|
||||||
MultiPart::alternative()
|
html.to_string(),
|
||||||
.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()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.expect("email built incorrectly");
|
.expect("email built incorrectly");
|
||||||
|
|
||||||
// don't worry about 'dangeous'. it's just that leaving it at the default configuration
|
// don't worry about 'dangeous'. it's just that leaving it at the default configuration
|
||||||
|
|
Loading…
Reference in a new issue