Skip to content

Commit d06a61e

Browse files
committed
coarse-grained Date instead of 1970
1 parent 193cf62 commit d06a61e

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/mimefactory.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -875,12 +875,27 @@ impl MimeFactory {
875875
}
876876
} else if is_encrypted && header_name == "date" {
877877
protected_headers.push(header.clone());
878-
unprotected_headers.push((
879-
"Date",
880-
mail_builder::headers::HeaderType::Raw(
881-
"Thu, 01 Jan 1970 00:00:00 +0000".into(),
882-
),
883-
));
878+
879+
// Coarse-grained date goes to unprotected header.
880+
//
881+
// We cannot just send "Thu, 01 Jan 1970 00:00:00 +0000"
882+
// or omit the header because GMX then fails with
883+
//
884+
// host mx00.emig.gmx.net[212.227.15.9] said:
885+
// 554-Transaction failed
886+
// 554-Reject due to policy restrictions.
887+
// 554 For explanation visit https://postmaster.gmx.net/en/case?...
888+
// (in reply to end of DATA command)
889+
//
890+
// and the explanation page says
891+
// "The time information deviates too much from the actual time".
892+
let coarse_grained_timestamp = self.timestamp - (self.timestamp % 1000000);
893+
let unprotected_date = chrono::DateTime::<chrono::Utc>::from_timestamp(coarse_grained_timestamp, 0)
894+
.unwrap()
895+
.to_rfc2822();
896+
unprotected_headers.push(("Date",
897+
mail_builder::headers::raw::Raw::new(unprotected_date).into())
898+
);
884899
} else if is_encrypted {
885900
protected_headers.push(header.clone());
886901

0 commit comments

Comments
 (0)