From ab29cd16e4e09767e955896c9c92c9ef6e649a9a Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 30 Dec 2007 21:29:08 +0000 Subject: [PATCH] Include a Date: header in mail sent by the CGI. We always use UTC rather than relying on the non-standard %z, though both Linux and OS X have it. Organization: Straylight/Edgeware From: rjk@greenend.org.uk <> --- lib/sendmail.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/sendmail.c b/lib/sendmail.c index 3ecfc40..63daee1 100644 --- a/lib/sendmail.c +++ b/lib/sendmail.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "syscalls.h" #include "log.h" @@ -117,7 +118,13 @@ static int sendmailfp(const char *tag, FILE *in, FILE *out, const char *ptr; uint8_t idbuf[20]; char *id; + struct tm ut; + time_t now; + char date[128]; + time(&now); + gmtime_r(&now, &ut); + strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S +0000", &ut); gcry_create_nonce(idbuf, sizeof idbuf); id = mime_to_base64(idbuf, sizeof idbuf); if((rc = getresponse(tag, in)) / 100 != 2) @@ -145,6 +152,7 @@ static int sendmailfp(const char *tag, FILE *in, FILE *out, || fprintf(out, "MIME-Version: 1.0\r\n") < 0 || fprintf(out, "Content-Type: %s\r\n", content_type) < 0 || fprintf(out, "Content-Transfer-Encoding: %s\r\n", encoding) < 0 + || fprintf(out, "Date: %s\r\n", date) < 0 || fprintf(out, "\r\n") < 0) { write_error: error(errno, "%s: write error", tag); -- [mdw]