Package: bsd-mailx / 8.1.2-0.20141216cvs-2

10-Reply-To-header.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
From: Robert Luberda <robert@debian.org>
Date: Mon, 2 Apr 2001 00:24:00 +0200
Subject: 10 Reply-To header.

Applied some patches from FreeBSD:
 + Add Relpy-To header if REPLYTO environment variable is set.
 + Add In-Reply-To header for replies (closes: #23115).
---
 cmd3.c    |  9 +++++++++
 collect.c | 11 ++++++++++-
 def.h     | 12 ++++++++----
 extern.h  |  2 +-
 mail.1    | 10 +++++++++-
 main.c    |  8 ++++++--
 names.c   |  3 ++-
 send.c    | 13 +++++++++++--
 8 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/cmd3.c b/cmd3.c
index 066161c..20a61c4 100644
--- a/cmd3.c
+++ b/cmd3.c
@@ -242,6 +242,9 @@ _respond(msgvec)
 		head.h_cc = NULL;
 	head.h_bcc = NULL;
 	head.h_smopts = NULL;
+	head.h_replyto = getenv("REPLYTO");
+	head.h_inreplyto = skin(hfield("message-id", mp));
+
 	mail1(&head, 1);
 	return(0);
 }
@@ -604,8 +607,10 @@ _Respond(int *msgvec)
 	struct message *mp;
 	int *ap;
 	char *cp;
+	char *mid;
 	memset(&head, 0, sizeof(head));
 
+	mid = NULL;
 	head.h_to = NULL;
 	for (ap = msgvec; *ap != 0; ap++) {
 		mp = &message[*ap - 1];
@@ -614,6 +619,7 @@ _Respond(int *msgvec)
 		if ((cp = skin(hfield("from", mp))) == NULL)
 			cp = skin(nameof(mp, 2));
 		head.h_to = cat(head.h_to, extract(cp, GTO));
+		mid = skin(hfield("message-id", mp));
 	}
 	if (head.h_to == NULL)
 		return(0);
@@ -624,6 +630,9 @@ _Respond(int *msgvec)
 	head.h_cc = NULL;
 	head.h_bcc = NULL;
 	head.h_smopts = NULL;
+	head.h_replyto = getenv("REPLYTO");
+	head.h_inreplyto = mid;
+
 	mail1(&head, 1);
 	return(0);
 }
diff --git a/collect.c b/collect.c
index 3bc16c3..708f257 100644
--- a/collect.c
+++ b/collect.c
@@ -218,13 +218,22 @@ cont:
 			break;
 		case 's':
 			/*
-			 * Set the Subject list.
+			 * Set the Subject line.
 			 */
 			cp = &linebuf[2];
 			while (isspace((unsigned char)*cp))
 				cp++;
 			hp->h_subject = savestr(cp);
 			break;
+               case 'R':
+                       /*
+                        * Set the Reply-To line.
+                        */
+                       cp = &linebuf[2];
+                       while (isspace(*cp))
+                               cp++;
+                       hp->h_replyto = savestr(cp);
+                       break;
 		case 'c':
 			/*
 			 * Add to the CC list.
diff --git a/def.h b/def.h
index 1905d00..0d1413a 100644
--- a/def.h
+++ b/def.h
@@ -165,12 +165,14 @@ struct headline {
 #define	GSUBJECT 2		/* Likewise, Subject: line */
 #define	GCC	4		/* And the Cc: line */
 #define	GBCC	8		/* And also the Bcc: line */
-#define	GMASK	(GTO|GSUBJECT|GCC|GBCC)
+#define	GREPLYTO 0x10           /* And the Reply-To: line */
+#define	GINREPLYTO 0x20         /* The In-Reply-To: line */
+#define	GMASK   (GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO)
 				/* Mask of places from whence */
 
-#define	GNL	16		/* Print blank line after */
-#define	GDEL	32		/* Entity removed from list */
-#define	GCOMMA	64		/* detract puts in commas */
+#define	GNL	0x40		/* Print blank line after */
+#define	GDEL	0x80		/* Entity removed from list */
+#define	GCOMMA	0x100		/* detract puts in commas */
 
 /*
  * Structure used to pass about the current
@@ -182,6 +184,8 @@ struct header {
 	char *h_header;			/* Additional header string */
 	struct name *h_cc;		/* Carbon copies string */
 	struct name *h_bcc;		/* Blind carbon copies */
+	char *h_replyto;                /* Reply address */
+	char *h_inreplyto;              /* Reference */
 	struct name *h_smopts;		/* Sendmail options */
 };
 
diff --git a/extern.h b/extern.h
index c3e5199..c888a9e 100644
--- a/extern.h
+++ b/extern.h
@@ -164,7 +164,7 @@ void	 load(char *);
 struct var *
 	 lookup(char *);
 int	 mail (struct name *, struct name *, struct name *, struct name *,
-	       char *, char *);
+	       char *, char *, char *);
 void	 mail1(struct header *, int);
 void	 makemessage(FILE *, int);
 void	 mark(int);
diff --git a/mail.1 b/mail.1
index 724f006..d212de2 100644
--- a/mail.1
+++ b/mail.1
@@ -841,6 +841,10 @@ Abort the message being sent, copying the message to
 in your home directory if
 .Ic save
 is set.
+.It Ic ~R Ns Ar string
+Use
+.Ar string
+as the Reply-To field.
 .Pp
 .It Ic ~r Ns Ar filename
 .It Ic ~< Ns Ar filename
@@ -1112,6 +1116,9 @@ variable is set.
 The default paginator
 .Xr more 1
 is used if this option is not defined.
+.It Ev REPLYTO
+If set, will be used to initialize the Reply-To field for outgoing
+messages.
 .It Ev SHELL
 Pathname of the shell to use in the
 .Ic !\&
@@ -1188,7 +1195,8 @@ utilizes the
 .Ev PAGER ,
 .Ev LISTER ,
 .Ev EDITOR ,
-.Ev VISUAL
+.Ev VISUAL ,
+.Ev REPLYTO ,
 .Ev MAIL ,
 .Ev MAILRC ,
 and
diff --git a/main.c b/main.c
index 9bcdd26..944c6ad 100644
--- a/main.c
+++ b/main.c
@@ -50,7 +50,8 @@ main(int argc, char **argv)
 	int i;
 	struct name *to, *cc, *bcc, *smopts;
 	char *subject;
-	char *header = NULL;
+	char *replyto;
+	char *header;
 	char *ef;
 	char* cmd;
 	char nosrc = 0;
@@ -110,6 +111,8 @@ main(int argc, char **argv)
 	bcc = NULL;
 	smopts = NULL;
 	subject = NULL;
+	header = NULL;
+	replyto = NULL;
 	while ((i = getopt(argc, argv, "EIN:a:b:c:defins:u:v")) != -1) {
 		switch (i) {
 		case 'u':
@@ -246,6 +249,7 @@ main(int argc, char **argv)
 	spreserve();
 	if (!nosrc)
 		load(_PATH_MASTER_RC);
+	replyto = getenv("REPLYTO");
 	/*
 	 * Expand returns a savestr, but load only uses the file name
 	 * for fopen, so it's safe to do this.
@@ -254,7 +258,7 @@ main(int argc, char **argv)
 		rc = "~/.mailrc";
 	load(expand(rc));
 	if (!rcvmode) {
-		mail(to, cc, bcc, smopts, subject, header);
+		mail(to, cc, bcc, smopts, subject, header, replyto);
 		/*
 		 * why wait?
 		 */
diff --git a/names.c b/names.c
index df6e4da..003aa75 100644
--- a/names.c
+++ b/names.c
@@ -256,7 +256,8 @@ outof(struct name *names, FILE *fo, struct header *hp)
 				goto cant;
 			}
 			fprintf(fout, "From %s %s", myname, date);
-			puthead(hp, fout, GTO|GSUBJECT|GCC|GNL);
+			puthead(hp, fout,
+				GTO|GSUBJECT|GCC|GREPLYTO|GINREPLYTO|GNL);
 			while ((c = getc(fo)) != EOF)
 				(void)putc(c, fout);
 			rewind(fo);
diff --git a/send.c b/send.c
index e79d9dc..f778fee 100644
--- a/send.c
+++ b/send.c
@@ -280,7 +280,7 @@ statusput(struct message *mp, FILE *obuf, char *prefix)
  */
 int
 mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts,
-     char *subject, char *header)
+     char *subject, char *header, char *replyto)
 {
 	struct header head;
 
@@ -289,6 +289,8 @@ mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts,
 	head.h_header = header;
 	head.h_cc = cc;
 	head.h_bcc = bcc;
+	head.h_replyto = replyto;
+	head.h_inreplyto = NULL;
 	head.h_smopts = smopts;
 	mail1(&head, 0);
 	return(0);
@@ -310,6 +312,8 @@ sendmail(void *v)
 	head.h_header = NULL;
 	head.h_cc = NULL;
 	head.h_bcc = NULL;
+	head.h_replyto = getenv("REPLYTO");
+	head.h_inreplyto = NULL;
 	head.h_smopts = NULL;
 	mail1(&head, 0);
 	return(0);
@@ -467,7 +471,8 @@ infix(struct header *hp, FILE *fi)
 		return(fi);
 	}
 	(void)rm(tempname);
-	(void)puthead(hp, nfo, GTO|GSUBJECT|GCC|GBCC|GNL|GCOMMA);
+	(void)puthead(hp, nfo,
+		      GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA);
 	c = getc(fi);
 	while (c != EOF) {
 		(void)putc(c, nfo);
@@ -514,6 +519,10 @@ puthead(struct header *hp, FILE *fo, int w)
 */
 	if (hp->h_header != NULL && w)
 		fprintf(fo, "%s\n", hp->h_header), gotcha++;
+        if (hp->h_replyto != NULL && w & GREPLYTO)
+                fprintf(fo, "Reply-To: %s\n", hp->h_replyto), gotcha++;
+        if (hp->h_inreplyto != NULL && w & GINREPLYTO)
+                fprintf(fo, "In-Reply-To: <%s>\n", hp->h_inreplyto), gotcha++;
 	if (gotcha && w & GNL)
 		(void)putc('\n', fo);
 	return(0);