Re: mail(1) MIME support [PATCH]
More changes: - I changed my overpopulated Message-ID for the function used by smtpd(8) (generate_uid()). Now the Message-ID generated by mail(1) is identical to the one generated by smtpd(8). - Added a conditional to skip adding the Message-ID if the machine doesn't have hostname yet. Also some clenage and ordering: - Moved included libraries to def.h - Moved function definitions to extern.h - Moved isutf8() and generate_uid() funcions to util.c Index: cmd3.c === RCS file: /cvs/src/usr.bin/mail/cmd3.c,v retrieving revision 1.30 diff -u -p -r1.30 cmd3.c --- cmd3.c 8 Mar 2023 04:43:11 - 1.30 +++ cmd3.c 11 Oct 2023 06:39:20 - @@ -238,6 +238,7 @@ _respond(int *msgvec) head.h_cc = np; } else head.h_cc = NULL; + head.h_msgid = hfield("message-id", mp); head.h_bcc = NULL; head.h_smopts = NULL; mail1(, 1); @@ -617,6 +618,7 @@ _Respond(int *msgvec) if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); + head.h_msgid = hfield("message-id", mp); head.h_from = NULL; head.h_cc = NULL; head.h_bcc = NULL; Index: collect.c === RCS file: /cvs/src/usr.bin/mail/collect.c,v retrieving revision 1.34 diff -u -p -r1.34 collect.c --- collect.c 17 Jan 2014 18:42:30 - 1.34 +++ collect.c 11 Oct 2023 06:39:20 - @@ -87,7 +87,7 @@ collect(struct header *hp, int printhead * refrain from printing a newline after * the headers (since some people mind). */ - t = GTO|GSUBJECT|GCC|GNL; + t = GTO|GSUBJECT|GMID|GCC|GNL; getsub = 0; if (hp->h_subject == NULL && value("interactive") != NULL && (value("ask") != NULL || value("asksub") != NULL)) @@ -208,7 +208,7 @@ cont: /* * Grab a bunch of headers. */ - grabh(hp, GTO|GSUBJECT|GCC|GBCC); + grabh(hp, GTO|GSUBJECT|GMID|GCC|GBCC); goto cont; case 't': /* @@ -328,7 +328,7 @@ cont: */ rewind(collf); puts("---\nMessage contains:"); - puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL); + puthead(hp, stdout, GTO|GSUBJECT|GMID|GCC|GBCC|GNL); while ((t = getc(collf)) != EOF) (void)putchar(t); goto cont; Index: def.h === RCS file: /cvs/src/usr.bin/mail/def.h,v retrieving revision 1.17 diff -u -p -r1.17 def.h --- def.h 28 Jan 2022 06:18:41 - 1.17 +++ def.h 11 Oct 2023 06:39:20 - @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include #include "pathnames.h" @@ -156,14 +158,15 @@ struct headline { #defineGTO 1 /* Grab To: line */ #defineGSUBJECT 2 /* Likewise, Subject: line */ -#defineGCC 4 /* And the Cc: line */ -#defineGBCC8 /* And also the Bcc: line */ -#defineGMASK (GTO|GSUBJECT|GCC|GBCC) +#defineGMID4 /* Message-ID: line */ +#defineGCC 8 /* And the Cc: line */ +#defineGBCC16 /* And also the Bcc: line */ +#defineGMASK (GTO|GSUBJECT|GMID|GCC|GBCC) /* Mask of places from whence */ -#defineGNL 16 /* Print blank line after */ -#defineGDEL32 /* Entity removed from list */ -#defineGCOMMA 64 /* detract puts in commas */ +#defineGNL 32 /* Print blank line after */ +#defineGDEL64 /* Entity removed from list */ +#defineGCOMMA 128 /* detract puts in commas */ /* * Structure used to pass about the current @@ -173,6 +176,7 @@ struct header { struct name *h_to; /* Dynamic "To:" string */ char *h_from; /* User-specified "From:" string */ char *h_subject;/* Subject string */ + char *h_msgid; /* Message-ID string */ struct name *h_cc; /* Carbon copies string */ struct name *h_bcc; /* Blind carbon copies */ struct name *h_smopts; /* Sendmail options */ Index: extern.h === RCS file: /cvs/src/usr.bin/mail/extern.h,v retrieving revision 1.29 diff -u -p -r1.29 extern.h --- extern.h16 Sep
Re: mail(1) MIME support [PATCH]
Added random number to Message-ID to get more unique string. Index: cmd3.c === RCS file: /cvs/src/usr.bin/mail/cmd3.c,v retrieving revision 1.30 diff -u -p -r1.30 cmd3.c --- cmd3.c 8 Mar 2023 04:43:11 - 1.30 +++ cmd3.c 10 Oct 2023 16:58:19 - @@ -238,6 +238,7 @@ _respond(int *msgvec) head.h_cc = np; } else head.h_cc = NULL; + head.h_msgid = hfield("message-id", mp); head.h_bcc = NULL; head.h_smopts = NULL; mail1(, 1); @@ -617,6 +618,7 @@ _Respond(int *msgvec) if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); + head.h_msgid = hfield("message-id", mp); head.h_from = NULL; head.h_cc = NULL; head.h_bcc = NULL; Index: collect.c === RCS file: /cvs/src/usr.bin/mail/collect.c,v retrieving revision 1.34 diff -u -p -r1.34 collect.c --- collect.c 17 Jan 2014 18:42:30 - 1.34 +++ collect.c 10 Oct 2023 16:58:19 - @@ -87,7 +87,7 @@ collect(struct header *hp, int printhead * refrain from printing a newline after * the headers (since some people mind). */ - t = GTO|GSUBJECT|GCC|GNL; + t = GTO|GSUBJECT|GMID|GCC|GNL; getsub = 0; if (hp->h_subject == NULL && value("interactive") != NULL && (value("ask") != NULL || value("asksub") != NULL)) @@ -208,7 +208,7 @@ cont: /* * Grab a bunch of headers. */ - grabh(hp, GTO|GSUBJECT|GCC|GBCC); + grabh(hp, GTO|GSUBJECT|GMID|GCC|GBCC); goto cont; case 't': /* @@ -328,7 +328,7 @@ cont: */ rewind(collf); puts("---\nMessage contains:"); - puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL); + puthead(hp, stdout, GTO|GSUBJECT|GMID|GCC|GBCC|GNL); while ((t = getc(collf)) != EOF) (void)putchar(t); goto cont; Index: def.h === RCS file: /cvs/src/usr.bin/mail/def.h,v retrieving revision 1.17 diff -u -p -r1.17 def.h --- def.h 28 Jan 2022 06:18:41 - 1.17 +++ def.h 10 Oct 2023 16:58:19 - @@ -156,14 +156,15 @@ struct headline { #defineGTO 1 /* Grab To: line */ #defineGSUBJECT 2 /* Likewise, Subject: line */ -#defineGCC 4 /* And the Cc: line */ -#defineGBCC8 /* And also the Bcc: line */ -#defineGMASK (GTO|GSUBJECT|GCC|GBCC) +#defineGMID4 /* Message-ID: line */ +#defineGCC 8 /* And the Cc: line */ +#defineGBCC16 /* And also the Bcc: line */ +#defineGMASK (GTO|GSUBJECT|GMID|GCC|GBCC) /* Mask of places from whence */ -#defineGNL 16 /* Print blank line after */ -#defineGDEL32 /* Entity removed from list */ -#defineGCOMMA 64 /* detract puts in commas */ +#defineGNL 32 /* Print blank line after */ +#defineGDEL64 /* Entity removed from list */ +#defineGCOMMA 128 /* detract puts in commas */ /* * Structure used to pass about the current @@ -173,6 +174,7 @@ struct header { struct name *h_to; /* Dynamic "To:" string */ char *h_from; /* User-specified "From:" string */ char *h_subject;/* Subject string */ + char *h_msgid; /* Message-ID string */ struct name *h_cc; /* Carbon copies string */ struct name *h_bcc; /* Blind carbon copies */ struct name *h_smopts; /* Sendmail options */ Index: extern.h === RCS file: /cvs/src/usr.bin/mail/extern.h,v retrieving revision 1.29 diff -u -p -r1.29 extern.h --- extern.h16 Sep 2018 02:38:57 - 1.29 +++ extern.h10 Oct 2023 16:58:19 - @@ -163,7 +163,7 @@ void load(char *); struct var * lookup(char *); int mail(struct name *, struct name *, struct name *, struct name *, - char *, char *); + char *, char *, char *); voidmail1(struct header *, int); voidmakemessage(FILE *, int); voidmark(int); Index: main.c === RCS file:
Re: mail(1) MIME support [PATCH]
Avoid printing some headers to stdout when responding from the interface (when you type r or R), especially Conten-Transfer-Enconding and Content-Type since the values showed before sending are not the ones that will be used after processing the body when sending. Index: cmd3.c === RCS file: /cvs/src/usr.bin/mail/cmd3.c,v retrieving revision 1.30 diff -u -p -r1.30 cmd3.c --- cmd3.c 8 Mar 2023 04:43:11 - 1.30 +++ cmd3.c 2 Oct 2023 16:02:02 - @@ -238,6 +238,7 @@ _respond(int *msgvec) head.h_cc = np; } else head.h_cc = NULL; + head.h_msgid = hfield("message-id", mp); head.h_bcc = NULL; head.h_smopts = NULL; mail1(, 1); @@ -617,6 +618,7 @@ _Respond(int *msgvec) if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); + head.h_msgid = hfield("message-id", mp); head.h_from = NULL; head.h_cc = NULL; head.h_bcc = NULL; Index: collect.c === RCS file: /cvs/src/usr.bin/mail/collect.c,v retrieving revision 1.34 diff -u -p -r1.34 collect.c --- collect.c 17 Jan 2014 18:42:30 - 1.34 +++ collect.c 2 Oct 2023 16:02:02 - @@ -87,7 +87,7 @@ collect(struct header *hp, int printhead * refrain from printing a newline after * the headers (since some people mind). */ - t = GTO|GSUBJECT|GCC|GNL; + t = GTO|GSUBJECT|GMID|GCC|GNL; getsub = 0; if (hp->h_subject == NULL && value("interactive") != NULL && (value("ask") != NULL || value("asksub") != NULL)) @@ -208,7 +208,7 @@ cont: /* * Grab a bunch of headers. */ - grabh(hp, GTO|GSUBJECT|GCC|GBCC); + grabh(hp, GTO|GSUBJECT|GMID|GCC|GBCC); goto cont; case 't': /* @@ -328,7 +328,7 @@ cont: */ rewind(collf); puts("---\nMessage contains:"); - puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL); + puthead(hp, stdout, GTO|GSUBJECT|GMID|GCC|GBCC|GNL); while ((t = getc(collf)) != EOF) (void)putchar(t); goto cont; Index: def.h === RCS file: /cvs/src/usr.bin/mail/def.h,v retrieving revision 1.17 diff -u -p -r1.17 def.h --- def.h 28 Jan 2022 06:18:41 - 1.17 +++ def.h 2 Oct 2023 16:02:02 - @@ -156,14 +156,15 @@ struct headline { #defineGTO 1 /* Grab To: line */ #defineGSUBJECT 2 /* Likewise, Subject: line */ -#defineGCC 4 /* And the Cc: line */ -#defineGBCC8 /* And also the Bcc: line */ -#defineGMASK (GTO|GSUBJECT|GCC|GBCC) +#defineGMID4 /* Message-ID: line */ +#defineGCC 8 /* And the Cc: line */ +#defineGBCC16 /* And also the Bcc: line */ +#defineGMASK (GTO|GSUBJECT|GMID|GCC|GBCC) /* Mask of places from whence */ -#defineGNL 16 /* Print blank line after */ -#defineGDEL32 /* Entity removed from list */ -#defineGCOMMA 64 /* detract puts in commas */ +#defineGNL 32 /* Print blank line after */ +#defineGDEL64 /* Entity removed from list */ +#defineGCOMMA 128 /* detract puts in commas */ /* * Structure used to pass about the current @@ -173,6 +174,7 @@ struct header { struct name *h_to; /* Dynamic "To:" string */ char *h_from; /* User-specified "From:" string */ char *h_subject;/* Subject string */ + char *h_msgid; /* Message-ID string */ struct name *h_cc; /* Carbon copies string */ struct name *h_bcc; /* Blind carbon copies */ struct name *h_smopts; /* Sendmail options */ Index: extern.h === RCS file: /cvs/src/usr.bin/mail/extern.h,v retrieving revision 1.29 diff -u -p -r1.29 extern.h --- extern.h16 Sep 2018 02:38:57 - 1.29 +++ extern.h2 Oct 2023 16:02:02 - @@ -163,7 +163,7 @@ void load(char *); struct var * lookup(char *); int mail(struct name *, struct name *, struct name *, struct name *, - char *, char *); + char *, char *, char *); void
Re: mail(1) MIME support [PATCH]
On Sun Oct 1 15:19:12 2023, Walter wrote > I decided to add another header, "Message-ID". Sending mails from my > patched mail(1) I realized that it's convenient the MUA itself add the > Message-ID (the one in this message was generated by my patch), if you > relegate this to the MTA, your MUA will save the local copy without that > header, then if more late you wish to read your mail with a > thread-capable MUA (eg Mutt), those messages won't be in the right > place. > To not break threads, one last detail was needed. Now mail(1) adds a In-Reply-To: header. Index: cmd3.c === RCS file: /cvs/src/usr.bin/mail/cmd3.c,v retrieving revision 1.30 diff -u -p -r1.30 cmd3.c --- cmd3.c 8 Mar 2023 04:43:11 - 1.30 +++ cmd3.c 2 Oct 2023 12:59:49 - @@ -238,6 +238,7 @@ _respond(int *msgvec) head.h_cc = np; } else head.h_cc = NULL; + head.h_msgid = hfield("message-id", mp); head.h_bcc = NULL; head.h_smopts = NULL; mail1(, 1); @@ -617,6 +618,7 @@ _Respond(int *msgvec) if ((head.h_subject = hfield("subject", mp)) == NULL) head.h_subject = hfield("subj", mp); head.h_subject = reedit(head.h_subject); + head.h_msgid = hfield("message-id", mp); head.h_from = NULL; head.h_cc = NULL; head.h_bcc = NULL; Index: collect.c === RCS file: /cvs/src/usr.bin/mail/collect.c,v retrieving revision 1.34 diff -u -p -r1.34 collect.c --- collect.c 17 Jan 2014 18:42:30 - 1.34 +++ collect.c 2 Oct 2023 12:59:49 - @@ -87,7 +87,7 @@ collect(struct header *hp, int printhead * refrain from printing a newline after * the headers (since some people mind). */ - t = GTO|GSUBJECT|GCC|GNL; + t = GTO|GSUBJECT|GMID|GCC|GNL; getsub = 0; if (hp->h_subject == NULL && value("interactive") != NULL && (value("ask") != NULL || value("asksub") != NULL)) @@ -208,7 +208,7 @@ cont: /* * Grab a bunch of headers. */ - grabh(hp, GTO|GSUBJECT|GCC|GBCC); + grabh(hp, GTO|GSUBJECT|GMID|GCC|GBCC); goto cont; case 't': /* @@ -328,7 +328,7 @@ cont: */ rewind(collf); puts("---\nMessage contains:"); - puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL); + puthead(hp, stdout, GTO|GSUBJECT|GMID|GCC|GBCC|GNL); while ((t = getc(collf)) != EOF) (void)putchar(t); goto cont; Index: def.h === RCS file: /cvs/src/usr.bin/mail/def.h,v retrieving revision 1.17 diff -u -p -r1.17 def.h --- def.h 28 Jan 2022 06:18:41 - 1.17 +++ def.h 2 Oct 2023 12:59:49 - @@ -156,14 +156,15 @@ struct headline { #defineGTO 1 /* Grab To: line */ #defineGSUBJECT 2 /* Likewise, Subject: line */ -#defineGCC 4 /* And the Cc: line */ -#defineGBCC8 /* And also the Bcc: line */ -#defineGMASK (GTO|GSUBJECT|GCC|GBCC) +#defineGMID4 /* Message-ID: line */ +#defineGCC 8 /* And the Cc: line */ +#defineGBCC16 /* And also the Bcc: line */ +#defineGMASK (GTO|GSUBJECT|GMID|GCC|GBCC) /* Mask of places from whence */ -#defineGNL 16 /* Print blank line after */ -#defineGDEL32 /* Entity removed from list */ -#defineGCOMMA 64 /* detract puts in commas */ +#defineGNL 32 /* Print blank line after */ +#defineGDEL64 /* Entity removed from list */ +#defineGCOMMA 128 /* detract puts in commas */ /* * Structure used to pass about the current @@ -173,6 +174,7 @@ struct header { struct name *h_to; /* Dynamic "To:" string */ char *h_from; /* User-specified "From:" string */ char *h_subject;/* Subject string */ + char *h_msgid; /* Message-ID string */ struct name *h_cc; /* Carbon copies string */ struct name *h_bcc; /* Blind carbon copies */ struct name *h_smopts; /* Sendmail options */ Index: extern.h === RCS file: /cvs/src/usr.bin/mail/extern.h,v retrieving revision 1.29 diff -u -p -r1.29 extern.h --- extern.h16 Sep 2018 02:38:57