From: Walter Alejandro Iglesias Subject: Re: mail(1) patches (UPDATE) To: tech@openbsd.org Date: Mon, 5 Aug 2024 13:58:32 +0200 If we forget about portability adding "Date" and "Message-ID" can be reduced to this: Index: send.c =================================================================== RCS file: /cvs/src/usr.bin/mail/send.c,v diff -u -p -r1.26 send.c --- send.c 8 Mar 2023 04:43:11 -0000 1.26 +++ send.c 5 Aug 2024 11:54:18 -0000 @@ -516,15 +516,29 @@ puthead(struct header *hp, FILE *fo, int { int gotcha; char *from; + time_t t = time(NULL); + struct tm tm = *localtime(&t); + char date[32]; + int hs, ts; + char hostname[1024]; + + hs = gethostname(hostname, 1023); + ts = strftime(date, sizeof(date), "%a, %d %b %Y %T %z", &tm); gotcha = 0; from = hp->h_from ? hp->h_from : value("from"); if (from != NULL) fprintf(fo, "From: %s\n", from), gotcha++; + if (fo != stdout && ts > 0) + fprintf(fo, "Date: %s\n", date), gotcha++; if (hp->h_to != NULL && w & GTO) fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++; if (hp->h_subject != NULL && w & GSUBJECT) fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++; + if (fo != stdout && hs == 0) + fprintf(fo, "Message-ID: <%d%02d%02d.%02d%02d%02d@%s>\n", + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, + tm.tm_min, tm.tm_sec, hostname), gotcha++; if (hp->h_cc != NULL && w & GCC) fmt("Cc:", hp->h_cc, fo, w&GCOMMA), gotcha++; if (hp->h_bcc != NULL && w & GBCC)