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.
This commit is contained in:
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 -Fr#xn
] [ ] [
.B -S
.I saveto
] [
.B -p[es] .B -p[es]
] [ ] [
.B -R .B -R
@ -104,6 +107,11 @@ as a recipient.
.BI -F .BI -F
file the message file the message
.TP .TP
.BI -S saveto
file the message into the
.I saveto
mailbox.
.TP
.BI -n .BI -n
intentionally no standard input intentionally no standard input
.TP .TP

View file

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