Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-22 05:10:29 +01:00
Use MultiPart::alternative_plain_html instead of manual impl
Dieser Commit ist enthalten in:
Ursprung
3713f2d134
Commit
68ec5f2a18
1 geänderte Dateien mit 2 neuen und 14 gelöschten Zeilen
16
src/mail.rs
16
src/mail.rs
|
@ -4,7 +4,7 @@ use chrono::NaiveDateTime;
|
||||||
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
|
||||||
|
|
||||||
use lettre::{
|
use lettre::{
|
||||||
message::{header, Mailbox, Message, MultiPart, SinglePart},
|
message::{Mailbox, Message, MultiPart},
|
||||||
transport::smtp::authentication::{Credentials, Mechanism as SmtpAuthMechanism},
|
transport::smtp::authentication::{Credentials, Mechanism as SmtpAuthMechanism},
|
||||||
transport::smtp::client::{Tls, TlsParameters},
|
transport::smtp::client::{Tls, TlsParameters},
|
||||||
transport::smtp::extension::ClientId,
|
transport::smtp::extension::ClientId,
|
||||||
|
@ -479,25 +479,13 @@ fn send_email(address: &str, subject: &str, body_html: String, body_text: String
|
||||||
|
|
||||||
let address = format!("{}@{}", address_split[1], domain_puny);
|
let address = format!("{}@{}", address_split[1], domain_puny);
|
||||||
|
|
||||||
let html = SinglePart::builder()
|
|
||||||
// We force Base64 encoding because in the past we had issues with different encodings.
|
|
||||||
.header(header::ContentTransferEncoding::Base64)
|
|
||||||
.header(header::ContentType::TEXT_HTML)
|
|
||||||
.body(body_html);
|
|
||||||
|
|
||||||
let text = SinglePart::builder()
|
|
||||||
// We force Base64 encoding because in the past we had issues with different encodings.
|
|
||||||
.header(header::ContentTransferEncoding::Base64)
|
|
||||||
.header(header::ContentType::TEXT_PLAIN)
|
|
||||||
.body(body_text);
|
|
||||||
|
|
||||||
let smtp_from = &CONFIG.smtp_from();
|
let smtp_from = &CONFIG.smtp_from();
|
||||||
let email = Message::builder()
|
let email = Message::builder()
|
||||||
.message_id(Some(format!("<{}@{}>", crate::util::get_uuid(), smtp_from.split('@').collect::<Vec<&str>>()[1])))
|
.message_id(Some(format!("<{}@{}>", crate::util::get_uuid(), smtp_from.split('@').collect::<Vec<&str>>()[1])))
|
||||||
.to(Mailbox::new(None, Address::from_str(&address)?))
|
.to(Mailbox::new(None, Address::from_str(&address)?))
|
||||||
.from(Mailbox::new(Some(CONFIG.smtp_from_name()), Address::from_str(smtp_from)?))
|
.from(Mailbox::new(Some(CONFIG.smtp_from_name()), Address::from_str(smtp_from)?))
|
||||||
.subject(subject)
|
.subject(subject)
|
||||||
.multipart(MultiPart::alternative().singlepart(text).singlepart(html))?;
|
.multipart(MultiPart::alternative_plain_html(body_text, body_html))?;
|
||||||
|
|
||||||
match mailer().send(&email) {
|
match mailer().send(&email) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
|
|
Laden …
In neuem Issue referenzieren