summaryrefslogtreecommitdiffstats
path: root/usr.bin/mail
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1998-01-02 16:44:13 +0000
committerjoerg <joerg@FreeBSD.org>1998-01-02 16:44:13 +0000
commit00289accda875898bb2dc93c3681d29d455634b9 (patch)
treec5616b133fbc09fe9fe5be1eed1d4fb141ca377f /usr.bin/mail
parent197f0b69d78a1b5722ee9fea48afbe26936aa5f2 (diff)
downloadFreeBSD-src-00289accda875898bb2dc93c3681d29d455634b9.zip
FreeBSD-src-00289accda875898bb2dc93c3681d29d455634b9.tar.gz
Teach boring old mail(1) about the use of the REPLYTO environment
variable which is de-facto standard for MUAs. Teach bomail to generate an in-reply-to header so threading MUAs and mail->news gateways won't lose context. While i was at it, removed two gratuitous standard violations for functions starting with an underscore.
Diffstat (limited to 'usr.bin/mail')
-rw-r--r--usr.bin/mail/cmd3.c20
-rw-r--r--usr.bin/mail/collect.c11
-rw-r--r--usr.bin/mail/def.h12
-rw-r--r--usr.bin/mail/extern.h6
-rw-r--r--usr.bin/mail/mail.19
-rw-r--r--usr.bin/mail/main.c9
-rw-r--r--usr.bin/mail/misc/mail.tildehelp1
-rw-r--r--usr.bin/mail/names.c3
-rw-r--r--usr.bin/mail/send.c15
9 files changed, 64 insertions, 22 deletions
diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c
index bb0c1e5..b4d7d44 100644
--- a/usr.bin/mail/cmd3.c
+++ b/usr.bin/mail/cmd3.c
@@ -187,9 +187,9 @@ respond(msgvec)
int *msgvec;
{
if (value("Replyall") == NOSTR)
- return (_respond(msgvec));
+ return (dorespond(msgvec));
else
- return (_Respond(msgvec));
+ return (doRespond(msgvec));
}
/*
@@ -197,7 +197,7 @@ respond(msgvec)
* message header and send them off to mail1()
*/
int
-_respond(msgvec)
+dorespond(msgvec)
int *msgvec;
{
struct message *mp;
@@ -252,6 +252,9 @@ _respond(msgvec)
head.h_cc = NIL;
head.h_bcc = NIL;
head.h_smopts = NIL;
+ if ((head.h_replyto = getenv("REPLYTO")) == NULL)
+ head.h_replyto = NOSTR;
+ head.h_inreplyto = skin(hfield("message-id", mp));
mail1(&head, 1);
return(0);
}
@@ -581,9 +584,9 @@ Respond(msgvec)
int *msgvec;
{
if (value("Replyall") == NOSTR)
- return (_Respond(msgvec));
+ return (doRespond(msgvec));
else
- return (_respond(msgvec));
+ return (dorespond(msgvec));
}
/*
@@ -592,13 +595,14 @@ Respond(msgvec)
* reply.
*/
int
-_Respond(msgvec)
+doRespond(msgvec)
int msgvec[];
{
struct header head;
struct message *mp;
register int *ap;
register char *cp;
+ char *mid;
head.h_to = NIL;
for (ap = msgvec; *ap != 0; ap++) {
@@ -608,6 +612,7 @@ _Respond(msgvec)
if ((cp = skin(hfield("from", mp))) == NOSTR)
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 == NIL)
return 0;
@@ -618,6 +623,9 @@ _Respond(msgvec)
head.h_cc = NIL;
head.h_bcc = NIL;
head.h_smopts = NIL;
+ if ((head.h_replyto = getenv("REPLYTO")) == NULL)
+ head.h_replyto = NOSTR;
+ head.h_inreplyto = mid;
mail1(&head, 1);
return 0;
}
diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index ab3a9a3..97f0794 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -232,13 +232,22 @@ cont:
break;
case 's':
/*
- * Set the Subject list.
+ * Set the Subject line.
*/
cp = &linebuf[2];
while (isspace(*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/usr.bin/mail/def.h b/usr.bin/mail/def.h
index 6ed65a4..f4f417a 100644
--- a/usr.bin/mail/def.h
+++ b/usr.bin/mail/def.h
@@ -155,12 +155,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
@@ -172,6 +174,8 @@ struct header {
char *h_subject; /* Subject 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/usr.bin/mail/extern.h b/usr.bin/mail/extern.h
index 508e281..24b7608 100644
--- a/usr.bin/mail/extern.h
+++ b/usr.bin/mail/extern.h
@@ -77,8 +77,8 @@ int More __P((int *));
int Pclose __P((FILE *));
int Respond __P((int *));
int Type __P((int *));
-int _Respond __P((int []));
-int _respond __P((int *));
+int doRespond __P((int []));
+int dorespond __P((int *));
void alter __P((char *));
int alternates __P((char **));
void announce __P((void));
@@ -162,7 +162,7 @@ void load __P((char *));
struct var *
lookup __P((char []));
int mail __P((struct name *,
- struct name *, struct name *, struct name *, char *));
+ struct name *, struct name *, struct name *, char *, char *));
void mail1 __P((struct header *, int));
void makemessage __P((FILE *));
void mark __P((int));
diff --git a/usr.bin/mail/mail.1 b/usr.bin/mail/mail.1
index 61c4dad..90fee5d 100644
--- a/usr.bin/mail/mail.1
+++ b/usr.bin/mail/mail.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mail.1 8.2 (Berkeley) 12/30/93
-.\" $Id: mail.1,v 1.12 1997/02/22 19:56:06 peter Exp $
+.\" $Id: mail.1,v 1.13 1997/11/01 00:56:15 jraynard Exp $
.\"
.Dd December 30, 1993
.Dt MAIL 1
@@ -752,6 +752,10 @@ in your home directory if
is set.
.It Ic \&~r Ns Ar filename
Read the named file into the message.
+.It Ic \&~R Ns Ar string
+Use
+.Ar string
+as the Reply-To field.
.It Ic \&~s Ns Ar string
Cause the named string to become the current subject field.
.It Ic \&~\&t Ns Ar name ...
@@ -924,6 +928,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 \&!
diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c
index d6499bb..7c66fa4 100644
--- a/usr.bin/mail/main.c
+++ b/usr.bin/mail/main.c
@@ -61,8 +61,8 @@ main(argc, argv)
{
register int i;
struct name *to, *cc, *bcc, *smopts;
- char *subject;
- char *ef;
+ char *subject, *replyto;
+ char *ef, *cp;
char nosrc = 0;
void hdrstop();
sig_t prevint;
@@ -90,6 +90,7 @@ main(argc, argv)
bcc = NIL;
smopts = NIL;
subject = NOSTR;
+ replyto = NOSTR;
while ((i = getopt(argc, argv, "INT:b:c:dfins:u:v")) != -1) {
switch (i) {
case 'T':
@@ -220,6 +221,8 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
if (*s != '\0')
load(s);
}
+ if ((cp = getenv("REPLYTO")) != NULL)
+ replyto = cp;
/*
* Expand returns a savestr, but load only uses the file name
@@ -227,7 +230,7 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
*/
load(expand("~/.mailrc"));
if (!rcvmode) {
- mail(to, cc, bcc, smopts, subject);
+ mail(to, cc, bcc, smopts, subject, replyto);
/*
* why wait?
*/
diff --git a/usr.bin/mail/misc/mail.tildehelp b/usr.bin/mail/misc/mail.tildehelp
index 0b1ab13..9c17176 100644
--- a/usr.bin/mail/misc/mail.tildehelp
+++ b/usr.bin/mail/misc/mail.tildehelp
@@ -12,6 +12,7 @@ The following ~ escapes are defined:
~p Print the message buffer
~m messages Read in messages, right shifted by a tab
~M messages Same as ~m, but keep all header lines
+~R address Set reply-to
~s subject Set subject
~t users Add users to to list
~v Invoke display editor on message
diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c
index e17e9f2..2050942 100644
--- a/usr.bin/mail/names.c
+++ b/usr.bin/mail/names.c
@@ -261,7 +261,8 @@ outof(names, fo, hp)
}
(void) fcntl(image, F_SETFD, 1);
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/usr.bin/mail/send.c b/usr.bin/mail/send.c
index 063e6ad..f9b7c87 100644
--- a/usr.bin/mail/send.c
+++ b/usr.bin/mail/send.c
@@ -251,9 +251,9 @@ statusput(mp, obuf, prefix)
* which does all the dirty work.
*/
int
-mail(to, cc, bcc, smopts, subject)
+mail(to, cc, bcc, smopts, subject, replyto)
struct name *to, *cc, *bcc, *smopts;
- char *subject;
+ char *subject, *replyto;
{
struct header head;
@@ -262,6 +262,8 @@ mail(to, cc, bcc, smopts, subject)
head.h_cc = cc;
head.h_bcc = bcc;
head.h_smopts = smopts;
+ head.h_replyto = replyto;
+ head.h_inreplyto = NOSTR;
mail1(&head, 0);
return(0);
}
@@ -282,6 +284,9 @@ sendmail(str)
head.h_cc = NIL;
head.h_bcc = NIL;
head.h_smopts = NIL;
+ if ((head.h_replyto = getenv("REPLYTO")) == NULL)
+ head.h_replyto = NOSTR;
+ head.h_inreplyto = NOSTR;
mail1(&head, 0);
return(0);
}
@@ -437,7 +442,7 @@ infix(hp, fi)
return(fi);
}
(void) rm(tempMail);
- (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);
@@ -483,6 +488,10 @@ puthead(hp, fo, w)
fmt("Cc:", hp->h_cc, fo, w&GCOMMA), gotcha++;
if (hp->h_bcc != NIL && w & GBCC)
fmt("Bcc:", hp->h_bcc, fo, w&GCOMMA), gotcha++;
+ if (hp->h_replyto != NOSTR && w && GREPLYTO)
+ fprintf(fo, "Reply-To: %s\n", hp->h_replyto), gotcha++;
+ if (hp->h_inreplyto != NOSTR && w && GINREPLYTO)
+ fprintf(fo, "In-Reply-To: <%s>\n", hp->h_inreplyto), gotcha++;
if (gotcha && w & GNL)
(void) putc('\n', fo);
return(0);
OpenPOWER on IntegriCloud