upas/marshal: add -S saveto to save outgoing mail, fix -F

Upas/marshal -F was broken with the '-8' command, and silly
without it: It used aliases passed on the command line, so
the destination address was ignored with -8 was passed.

In addition, it would create a new mailbox for any aliases
being sent to, instead of putting them all in one location.

The new -S option is similar to -F, but specifies where the
message should go.
front
Ori Bernstein 2020-11-06 18:15:15 -08:00
parent 6f15a730f3
commit 4257a5292a
2 changed files with 17 additions and 5 deletions

View File

@ -15,6 +15,9 @@ marshal \- formatting and sending mail
] [
.B -Fr#xn
] [
.B -S
.I saveto
] [
.B -p[es]
] [
.B -R
@ -104,6 +107,11 @@ as a recipient.
.BI -F
file the message
.TP
.BI -S saveto
file the message into the
.I saveto
mailbox.
.TP
.BI -n
intentionally no standard input
.TP

View File

@ -193,7 +193,7 @@ void
main(int argc, char **argv)
{
int ccargc, bccargc, flags, fd, noinput, headersrv;
char *subject, *type, *boundary;
char *subject, *type, *boundary, *saveto;
char *ccargv[32], *bccargv[32];
Addr *to, *cc, *bcc;
Attach *first, **l, *a;
@ -207,6 +207,7 @@ main(int argc, char **argv)
l = &first;
type = nil;
hdrstring = nil;
saveto = nil;
ccargc = bccargc = 0;
tmfmtinstall();
@ -244,6 +245,9 @@ main(int argc, char **argv)
case 'F':
Fflag = 1; /* file message */
break;
case 'S':
saveto = EARGF(usage());
break;
case 'n': /* no standard input */
nflag = 1;
break;
@ -336,7 +340,9 @@ main(int argc, char **argv)
}
}
fd = sendmail(to, cc, bcc, &pid, Fflag ? argv[0] : nil);
if(Fflag)
saveto=argc>0?argv[0]:to->v;
fd = sendmail(to, cc, bcc, &pid, saveto);
if(fd < 0)
sysfatal("execing sendmail: %r\n:");
if(xflag || lbflag || dflag){
@ -1079,10 +1085,8 @@ sendmail(Addr *to, Addr *cc, Addr *bcc, int *pid, char *rcvr)
break;
case 0:
close(pfd[0]);
b = 0;
/* BOTCH; "From " time gets changed */
if(rcvr)
b = openfolder(foldername(nil, user, rcvr), time(0));
b = openfolder(foldername(nil, user, rcvr), time(0));
fd = b? Bfildes(b): -1;
printunixfrom(fd);
tee(0, pfd[1], fd);