Skip to content

Commit ebb7ce8

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

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/mimefactory.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,28 @@ impl MimeFactory {
875875
}
876876
} else if is_encrypted && header_name == "date" {
877877
protected_headers.push(header.clone());
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 =
894+
chrono::DateTime::<chrono::Utc>::from_timestamp(coarse_grained_timestamp, 0)
895+
.unwrap()
896+
.to_rfc2822();
878897
unprotected_headers.push((
879898
"Date",
880-
mail_builder::headers::HeaderType::Raw(
881-
"Thu, 01 Jan 1970 00:00:00 +0000".into(),
882-
),
899+
mail_builder::headers::raw::Raw::new(unprotected_date).into(),
883900
));
884901
} else if is_encrypted {
885902
protected_headers.push(header.clone());

0 commit comments

Comments
 (0)