1
0
Fork 0

Change the mails content types to more closely match what we sent before

Dieser Commit ist enthalten in:
Daniel García 2020-05-07 00:50:30 +02:00
Ursprung 4ff15f6dc2
Commit 6c5e35ce5c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: FC8A7D14C3CD543A
4 geänderte Dateien mit 30 neuen und 19 gelöschten Zeilen

2
Cargo.lock generiert
Datei anzeigen

@ -1046,7 +1046,7 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
[[package]]
name = "lettre"
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 = [
"base64 0.12.0",
"bufstream",

Datei anzeigen

@ -123,7 +123,7 @@ rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fa
rocket_contrib = { git = 'https://github.com/SergioBenitez/Rocket', rev = '1010f6a2a88fac899dec0cd2f642156908038a53' }
# 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
data-url = { git = 'https://github.com/servo/rust-url', package="data-url", rev = '7f1bd6ce1c2fde599a757302a843a60e714c5f72' }

Datei anzeigen

@ -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,
FromStrError(FromStrErr): _has_source, _api_error,
}
// This is implemented by hand because NoneError doesn't implement neither Display nor Error

Datei anzeigen

@ -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(())