mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2024-12-23 03:19:03 +00:00
Change the mails content types to more closely match what we sent before
This commit is contained in:
parent
4ff15f6dc2
commit
6c5e35ce5c
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1046,7 +1046,7 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "lettre"
|
name = "lettre"
|
||||||
version = "0.10.0-pre"
|
version = "0.10.0-pre"
|
||||||
source = "git+https://github.com/lettre/lettre?rev=88df2a502d537ebfdd4218fb6b9f4168fb0f7943#88df2a502d537ebfdd4218fb6b9f4168fb0f7943"
|
source = "git+https://github.com/lettre/lettre?rev=2ade0b884630ce1125ffc1011e8604244c1e62e5#2ade0b884630ce1125ffc1011e8604244c1e62e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.12.0",
|
"base64 0.12.0",
|
||||||
"bufstream",
|
"bufstream",
|
||||||
|
@ -123,7 +123,7 @@ rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fa
|
|||||||
rocket_contrib = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fac899dec0cd2f642156908038a53' }
|
rocket_contrib = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fac899dec0cd2f642156908038a53' }
|
||||||
|
|
||||||
# Use git version for timeout fix #706
|
# Use git version for timeout fix #706
|
||||||
lettre = { git = 'https://github.com/lettre/lettre', rev = '88df2a502d537ebfdd4218fb6b9f4168fb0f7943' }
|
lettre = { git = 'https://github.com/lettre/lettre', rev = '2ade0b884630ce1125ffc1011e8604244c1e62e5' }
|
||||||
|
|
||||||
# For favicon extraction from main website
|
# For favicon extraction from main website
|
||||||
data-url = { git = 'https://github.com/servo/rust-url', package="data-url", rev = '7f1bd6ce1c2fde599a757302a843a60e714c5f72' }
|
data-url = { git = 'https://github.com/servo/rust-url', package="data-url", rev = '7f1bd6ce1c2fde599a757302a843a60e714c5f72' }
|
||||||
|
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 std::time::SystemTimeError as TimeErr;
|
||||||
use u2f::u2ferror::U2fError as U2fErr;
|
use u2f::u2ferror::U2fError as U2fErr;
|
||||||
use yubico::yubicoerror::YubicoError as YubiErr;
|
use yubico::yubicoerror::YubicoError as YubiErr;
|
||||||
use lettre::error::Error as LettreErr;
|
|
||||||
use lettre::address::AddressError as AddrErr;
|
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;
|
use lettre::transport::smtp::error::Error as SmtpErr;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@ -75,9 +77,11 @@ make_error! {
|
|||||||
ReqError(ReqErr): _has_source, _api_error,
|
ReqError(ReqErr): _has_source, _api_error,
|
||||||
RegexError(RegexErr): _has_source, _api_error,
|
RegexError(RegexErr): _has_source, _api_error,
|
||||||
YubiError(YubiErr): _has_source, _api_error,
|
YubiError(YubiErr): _has_source, _api_error,
|
||||||
LetreError(LettreErr):_has_source, _api_error,
|
|
||||||
AddressError(AddrErr):_has_source, _api_error,
|
LetreError(LettreErr): _has_source, _api_error,
|
||||||
SmtpError(SmtpErr): _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
|
// 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 address = format!("{}@{}", address_split[1], domain_puny);
|
||||||
|
|
||||||
let html = SinglePart::builder()
|
let data = MultiPart::mixed()
|
||||||
.header(header::ContentType("text/html; charset=utf-8".parse().unwrap()))
|
.multipart(
|
||||||
.header(header::ContentTransferEncoding::QuotedPrintable)
|
MultiPart::alternative()
|
||||||
.body(body_html);
|
.singlepart(
|
||||||
|
SinglePart::quoted_printable()
|
||||||
let text = SinglePart::builder()
|
.header(header::ContentType("text/plain; charset=utf-8".parse()?))
|
||||||
.header(header::ContentType("text/plain; charset=utf-8".parse().unwrap()))
|
.body(body_text),
|
||||||
.header(header::ContentTransferEncoding::QuotedPrintable)
|
)
|
||||||
.body(body_text);
|
.multipart(
|
||||||
|
MultiPart::related().singlepart(
|
||||||
let alternative = MultiPart::alternative().singlepart(text).singlepart(html);
|
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()
|
let email = Message::builder()
|
||||||
.to(Mailbox::new(None, Address::from_str(&address)?))
|
.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())?,
|
Address::from_str(&CONFIG.smtp_from())?,
|
||||||
))
|
))
|
||||||
.subject(subject)
|
.subject(subject)
|
||||||
.multipart(alternative)
|
.multipart(data)?;
|
||||||
.map_err(|e| Error::new("Error building email", e.to_string()))?;
|
|
||||||
|
|
||||||
let _ = mailer().send(&email)?;
|
let _ = mailer().send(&email)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user