mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-05-21 19:13:57 +00:00
Change the mails content types to more closely match what we sent before
This commit is contained in:
parent
4ff15f6dc2
commit
6c5e35ce5c
4 changed files with 30 additions and 19 deletions
12
src/error.rs
12
src/error.rs
|
@ -45,8 +45,10 @@ use std::option::NoneError as NoneErr;
|
|||
use std::time::SystemTimeError as TimeErr;
|
||||
use u2f::u2ferror::U2fError as U2fErr;
|
||||
use yubico::yubicoerror::YubicoError as YubiErr;
|
||||
use lettre::error::Error as LettreErr;
|
||||
|
||||
use lettre::address::AddressError as AddrErr;
|
||||
use lettre::error::Error as LettreErr;
|
||||
use lettre::message::mime::FromStrError as FromStrErr;
|
||||
use lettre::transport::smtp::error::Error as SmtpErr;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -75,9 +77,11 @@ make_error! {
|
|||
ReqError(ReqErr): _has_source, _api_error,
|
||||
RegexError(RegexErr): _has_source, _api_error,
|
||||
YubiError(YubiErr): _has_source, _api_error,
|
||||
LetreError(LettreErr):_has_source, _api_error,
|
||||
AddressError(AddrErr):_has_source, _api_error,
|
||||
SmtpError(SmtpErr): _has_source, _api_error,
|
||||
|
||||
LetreError(LettreErr): _has_source, _api_error,
|
||||
AddressError(AddrErr): _has_source, _api_error,
|
||||
SmtpError(SmtpErr): _has_source, _api_error,
|
||||
FromStrError(FromStrErr): _has_source, _api_error,
|
||||
}
|
||||
|
||||
// This is implemented by hand because NoneError doesn't implement neither Display nor Error
|
||||
|
|
33
src/mail.rs
33
src/mail.rs
|
@ -278,17 +278,25 @@ fn send_email(address: &str, subject: &str, body_html: &str, body_text: &str) ->
|
|||
|
||||
let address = format!("{}@{}", address_split[1], domain_puny);
|
||||
|
||||
let html = SinglePart::builder()
|
||||
.header(header::ContentType("text/html; charset=utf-8".parse().unwrap()))
|
||||
.header(header::ContentTransferEncoding::QuotedPrintable)
|
||||
.body(body_html);
|
||||
|
||||
let text = SinglePart::builder()
|
||||
.header(header::ContentType("text/plain; charset=utf-8".parse().unwrap()))
|
||||
.header(header::ContentTransferEncoding::QuotedPrintable)
|
||||
.body(body_text);
|
||||
|
||||
let alternative = MultiPart::alternative().singlepart(text).singlepart(html);
|
||||
let data = MultiPart::mixed()
|
||||
.multipart(
|
||||
MultiPart::alternative()
|
||||
.singlepart(
|
||||
SinglePart::quoted_printable()
|
||||
.header(header::ContentType("text/plain; charset=utf-8".parse()?))
|
||||
.body(body_text),
|
||||
)
|
||||
.multipart(
|
||||
MultiPart::related().singlepart(
|
||||
SinglePart::quoted_printable()
|
||||
.header(header::ContentType("text/html; charset=utf-8".parse()?))
|
||||
.body(body_html),
|
||||
)
|
||||
// .singlepart(SinglePart::base64() -- Inline files would go here
|
||||
),
|
||||
)
|
||||
// .singlepart(SinglePart::base64() -- Attachments would go here
|
||||
;
|
||||
|
||||
let email = Message::builder()
|
||||
.to(Mailbox::new(None, Address::from_str(&address)?))
|
||||
|
@ -297,8 +305,7 @@ fn send_email(address: &str, subject: &str, body_html: &str, body_text: &str) ->
|
|||
Address::from_str(&CONFIG.smtp_from())?,
|
||||
))
|
||||
.subject(subject)
|
||||
.multipart(alternative)
|
||||
.map_err(|e| Error::new("Error building email", e.to_string()))?;
|
||||
.multipart(data)?;
|
||||
|
||||
let _ = mailer().send(&email)?;
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue