Merge pull request #421 from Zoruk/v0.9.x-fix-attachment

Fix attachment line length
This commit is contained in:
Alexis Mousset
2020-05-06 11:07:22 +02:00
committed by GitHub

View File

@@ -271,7 +271,13 @@ impl EmailBuilder {
filename: &str,
content_type: &Mime,
) -> Result<EmailBuilder, Error> {
let encoded_body = base64::encode(&body);
let encoded_body = base64::encode(&body)
.as_bytes()
.chunks(72)
// base64 encoding is guaranteed to return utf-8, so this won't panic
.map(|s| std::str::from_utf8(s).unwrap())
.collect::<Vec<_>>()
.join("\r\n");
let content = PartBuilder::new()
.body(encoded_body)
.header((