diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-01-20 16:59:08 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-01-20 16:59:08 +0000 |
commit | 8de2b8964d4a3b45960e3733ecf815576a70af3f (patch) | |
tree | ef1146a628e10e5574584a3ba6f4f4de7318c98e /usr.bin/mail/main.c | |
parent | daca61ed003d5bfaddce1c6097a077fbda4d3748 (diff) |
Add support for the "-r fromaddr" flag now that we don't support
sendmail flags on the command line.
Also allow "from" to be set in mailrc.
Use sendmail's "-t" flag when executing sendmail instead of specifying
the list of recipients in argv. The "-f" flag will be used to set
the from address if specified.
Diffstat (limited to 'usr.bin/mail/main.c')
-rw-r--r-- | usr.bin/mail/main.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c index 2dfde98ef28..eb02c18b57c 100644 --- a/usr.bin/mail/main.c +++ b/usr.bin/mail/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.27 2015/01/16 06:40:09 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.28 2015/01/20 16:59:07 millert Exp $ */ /* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */ /* @@ -49,6 +49,7 @@ main(int argc, char **argv) { int i; struct name *to, *cc, *bcc, *smopts; + char *fromaddr; char *subject; char *ef; char nosrc = 0; @@ -77,8 +78,9 @@ main(int argc, char **argv) cc = NULL; bcc = NULL; smopts = NULL; + fromaddr = NULL; subject = NULL; - while ((i = getopt(argc, argv, "EIN:b:c:dfins:u:v")) != -1) { + while ((i = getopt(argc, argv, "EIN:b:c:dfinr:s:u:v")) != -1) { switch (i) { case 'u': /* @@ -100,6 +102,12 @@ main(int argc, char **argv) case 'd': debug++; break; + case 'r': + /* + * Set From: address + */ + fromaddr = optarg; + break; case 's': /* * Give a subject field for sending from @@ -203,7 +211,7 @@ main(int argc, char **argv) rc = "~/.mailrc"; load(expand(rc)); if (!rcvmode) { - mail(to, cc, bcc, smopts, subject); + mail(to, cc, bcc, smopts, fromaddr, subject); /* * why wait? */ @@ -272,7 +280,7 @@ usage(void) { fprintf(stderr, "usage: %s [-dEIinv] [-b list] [-c list] " - "[-s subject] to-addr ...\n", __progname); + "[-r from-addr] [-s subject] to-addr ...\n", __progname); fprintf(stderr, " %s [-dEIiNnv] -f [file]\n", __progname); fprintf(stderr, " %s [-dEIiNnv] [-u user]\n", __progname); exit(1); |