From 418bb3fe47411777c566fed202412780f0b318be Mon Sep 17 00:00:00 2001 From: Andinus Date: Fri, 22 May 2020 12:12:11 +0530 Subject: [PATCH] Add Date header to emails UTC time is used because we cannot format time as "Fri, 22 May 2020 06:33:00 +0000" with the times package. "zz" returns +00 & "zzz" returns +00:00, note that the former doesn't return minutes value so it'll return +05 for systems in timezone +0530 & "zzz" will return +05:30 for the same. Instead of parsing it again & removing ':' manually we use UTC time & add "+0000". --- src/email.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/email.nim b/src/email.nim index f89f010..e29dc54 100644 --- a/src/email.nim +++ b/src/email.nim @@ -56,6 +56,9 @@ proc sendMail( var headers = otherHeaders headers.add(("From", mailer.config.smtpFromAddr)) + let dateHeader = now().utc().format("ddd, dd MMM yyyy hh:mm:ss") & " +0000" + headers.add(("Date", dateHeader)) + let encoded = createMessage(subject, message, toList, @[], headers)