10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
55387Sny155746 * Common Development and Distribution License (the "License").
65387Sny155746 * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate
220Sstevel@tonic-gate /*
23*13093SRoger.Faulkner@Oracle.COM * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
26*13093SRoger.Faulkner@Oracle.COM /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27*13093SRoger.Faulkner@Oracle.COM /* All Rights Reserved */
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include "mail.h"
305387Sny155746 #include <sys/param.h>
310Sstevel@tonic-gate /*
325387Sny155746 * Send mail - High level sending routine
330Sstevel@tonic-gate */
345387Sny155746 void
sendmail(argc,argv)355387Sny155746 sendmail(argc, argv)
360Sstevel@tonic-gate char **argv;
370Sstevel@tonic-gate {
380Sstevel@tonic-gate char **args;
390Sstevel@tonic-gate char *tp, *zp;
405387Sny155746 char buf[2048], last1c;
410Sstevel@tonic-gate FILE *input;
425387Sny155746 struct stat64 sbuf;
430Sstevel@tonic-gate int aret;
440Sstevel@tonic-gate int i, n;
455387Sny155746 int oldn = 1;
460Sstevel@tonic-gate int ttyf = 0;
470Sstevel@tonic-gate int pushrest = 0;
480Sstevel@tonic-gate int hdrtyp = 0;
490Sstevel@tonic-gate int ctf = FALSE;
500Sstevel@tonic-gate int binflg = 0;
510Sstevel@tonic-gate long count = 0L;
520Sstevel@tonic-gate struct tm *bp;
530Sstevel@tonic-gate struct hdrs *hptr;
540Sstevel@tonic-gate static char pn[] = "sendmail";
550Sstevel@tonic-gate reciplist list;
560Sstevel@tonic-gate
570Sstevel@tonic-gate Dout(pn, 0, "entered\n");
580Sstevel@tonic-gate new_reciplist(&list);
590Sstevel@tonic-gate for (i = 1; i < argc; ++i) {
605387Sny155746 if (argv[i][0] == '-') {
615387Sny155746 if (argv[i][1] == '\0') {
625387Sny155746 errmsg(E_SYNTAX,
635387Sny155746 "Hyphens MAY NOT be followed by spaces");
640Sstevel@tonic-gate }
655387Sny155746 if (i > 1) {
665387Sny155746 errmsg(E_SYNTAX,
675387Sny155746 "Options MUST PRECEDE persons");
680Sstevel@tonic-gate }
695387Sny155746 done(0);
705387Sny155746 }
710Sstevel@tonic-gate /*
725387Sny155746 * Ensure no NULL names in list
735387Sny155746 */
745387Sny155746 if (argv[i][0] == '\0' || argv[i][strlen(argv[i])-1] == '!') {
755387Sny155746 errmsg(E_SYNTAX, "Null names are not allowed");
765387Sny155746 done(0);
770Sstevel@tonic-gate }
785387Sny155746 /* Don't check for duplication */
795387Sny155746 add_recip(&list, argv[i], FALSE);
800Sstevel@tonic-gate }
810Sstevel@tonic-gate
820Sstevel@tonic-gate mktmp();
830Sstevel@tonic-gate /*
845387Sny155746 * Format time
855387Sny155746 */
860Sstevel@tonic-gate time(&iop);
870Sstevel@tonic-gate bp = localtime(&iop);
880Sstevel@tonic-gate tp = asctime(bp);
890Sstevel@tonic-gate zp = tzname[bp->tm_isdst];
900Sstevel@tonic-gate sprintf(datestring, "%.16s %.3s %.5s", tp, zp, tp+20);
915387Sny155746 trimnl(datestring);
920Sstevel@tonic-gate /* asctime: Fri Sep 30 00:00:00 1986\n */
935387Sny155746 /* 0123456789012345678901234 */
940Sstevel@tonic-gate /* RFCtime: Fri, 28 Jul 89 10:30 EDT */
950Sstevel@tonic-gate sprintf(RFC822datestring, "%.3s, %.2s %.3s %.4s %.5s %.3s",
960Sstevel@tonic-gate tp, tp+8, tp+4, tp+20, tp+11, zp);
970Sstevel@tonic-gate
980Sstevel@tonic-gate /*
995387Sny155746 * Write out the from line header for the letter
1005387Sny155746 */
1010Sstevel@tonic-gate if (fromflag && deliverflag && from_user[0] != '\0') {
1025387Sny155746 (void) snprintf(buf, sizeof (buf), "%s%s %s\n",
1030Sstevel@tonic-gate header[H_FROM].tag, from_user, datestring);
1040Sstevel@tonic-gate } else {
1055387Sny155746 (void) snprintf(buf, sizeof (buf), "%s%s %s\n",
1060Sstevel@tonic-gate header[H_FROM].tag, my_name, datestring);
1070Sstevel@tonic-gate }
1080Sstevel@tonic-gate if (!wtmpf(buf, strlen(buf))) {
1090Sstevel@tonic-gate done(0);
1100Sstevel@tonic-gate }
1110Sstevel@tonic-gate savehdrs(buf, H_FROM);
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate /*
1145387Sny155746 * Copy to list in mail entry?
1155387Sny155746 */
1160Sstevel@tonic-gate if (flgt == 1 && argc > 1) {
1170Sstevel@tonic-gate aret = argc;
1180Sstevel@tonic-gate args = argv;
1190Sstevel@tonic-gate while (--aret > 0) {
1205387Sny155746 (void) snprintf(buf, sizeof (buf),
1215387Sny155746 "%s %s\n", header[H_TO].tag, *++args);
1220Sstevel@tonic-gate if (!wtmpf(buf, strlen(buf))) {
1230Sstevel@tonic-gate done(0);
1240Sstevel@tonic-gate }
1250Sstevel@tonic-gate savehdrs(buf, H_TO);
1260Sstevel@tonic-gate }
1270Sstevel@tonic-gate }
1280Sstevel@tonic-gate
1290Sstevel@tonic-gate flgf = 1; /* reset when first read of message body succeeds */
1300Sstevel@tonic-gate /*
1315387Sny155746 * Read mail message, allowing for lines of infinite
1325387Sny155746 * length. This is tricky, have to watch for newlines.
1335387Sny155746 */
1340Sstevel@tonic-gate saveint = setsig(SIGINT, savdead);
1350Sstevel@tonic-gate last1c = ' '; /* anything other than newline */
1365387Sny155746 ttyf = isatty(fileno(stdin));
1370Sstevel@tonic-gate pushrest = 0;
1380Sstevel@tonic-gate
1390Sstevel@tonic-gate /*
1400Sstevel@tonic-gate * scan header & save relevant info.
1410Sstevel@tonic-gate */
1420Sstevel@tonic-gate (void) strlcpy(fromU, my_name, sizeof (fromU));
1430Sstevel@tonic-gate fromS[0] = 0; /* set up for >From scan */
1440Sstevel@tonic-gate input = stdin;
1455387Sny155746 /*
1465387Sny155746 * Fifofs cannot handle if the inode number crosses
1475387Sny155746 * 32-bit limit. This results in overflow, if the
1485387Sny155746 * input steam is a pipe. Using 64-bit interface to
1495387Sny155746 * take care of that.
1505387Sny155746 */
1515387Sny155746 if (fstat64(fileno(input), &sbuf) == 0) {
1525387Sny155746 /* Also care if we could not handle large mail. */
1535387Sny155746 if ((sbuf.st_size > MAXOFF_T) || (sbuf.st_blocks > LONG_MAX)) {
1545387Sny155746 fprintf(stderr, "%s: stdin: %s\n", program,
1555387Sny155746 strerror(EOVERFLOW));
1560Sstevel@tonic-gate exit(1);
1570Sstevel@tonic-gate }
1580Sstevel@tonic-gate }
1590Sstevel@tonic-gate
160*13093SRoger.Faulkner@Oracle.COM while ((n = getaline(line, sizeof (line), stdin)) > 0) {
1610Sstevel@tonic-gate last1c = line[n-1];
1620Sstevel@tonic-gate if (pushrest) {
1635387Sny155746 if (!wtmpf(line, n)) {
1640Sstevel@tonic-gate done(0);
1650Sstevel@tonic-gate }
1660Sstevel@tonic-gate pushrest = (last1c != '\n');
1670Sstevel@tonic-gate continue;
1680Sstevel@tonic-gate }
1690Sstevel@tonic-gate pushrest = (last1c != '\n');
1700Sstevel@tonic-gate
1715387Sny155746 if ((hdrtyp = isheader(line, &ctf)) == FALSE) {
1720Sstevel@tonic-gate break;
1730Sstevel@tonic-gate }
1740Sstevel@tonic-gate flgf = 0;
1750Sstevel@tonic-gate switch (hdrtyp) {
1760Sstevel@tonic-gate case H_RVERS:
1770Sstevel@tonic-gate /* Are we dealing with a delivery report? */
1780Sstevel@tonic-gate /* dflag = 9 ==> do not return on failure */
1790Sstevel@tonic-gate dflag = 9;
1800Sstevel@tonic-gate Dout(pn, 0, "dflag = 9\n");
1810Sstevel@tonic-gate break;
1820Sstevel@tonic-gate case H_FROM:
1830Sstevel@tonic-gate if (!wtmpf(">", 1)) {
1840Sstevel@tonic-gate done(0);
1850Sstevel@tonic-gate }
1860Sstevel@tonic-gate /* note dropthru */
1870Sstevel@tonic-gate hdrtyp = H_FROM1;
1880Sstevel@tonic-gate case H_FROM1:
1890Sstevel@tonic-gate if (substr(line, "forwarded by") > -1) {
1900Sstevel@tonic-gate break;
1910Sstevel@tonic-gate }
1925387Sny155746 pickFrom(line);
1930Sstevel@tonic-gate if (Rpath[0] != '\0') {
1940Sstevel@tonic-gate strcat(Rpath, "!");
1950Sstevel@tonic-gate }
1960Sstevel@tonic-gate (void) strlcat(Rpath, fromS, sizeof (Rpath));
1970Sstevel@tonic-gate n = 0; /* don't copy remote from's into mesg. */
1980Sstevel@tonic-gate break;
1990Sstevel@tonic-gate case H_MIMEVERS:
2000Sstevel@tonic-gate case H_CLEN:
2010Sstevel@tonic-gate case H_CTYPE:
2020Sstevel@tonic-gate /* suppress it: only generated if needed */
2030Sstevel@tonic-gate n = 0; /* suppress */
2040Sstevel@tonic-gate break;
2050Sstevel@tonic-gate case H_TCOPY:
2060Sstevel@tonic-gate /* Write out placeholder for later */
2075387Sny155746 (void) snprintf(buf, sizeof (buf), "%s \n",
2085387Sny155746 header[H_TCOPY].tag);
2090Sstevel@tonic-gate if (!wtmpf(buf, strlen(buf))) {
2100Sstevel@tonic-gate done(0);
2110Sstevel@tonic-gate }
2120Sstevel@tonic-gate n = 0; /* suppress */
2130Sstevel@tonic-gate break;
2140Sstevel@tonic-gate case H_MTYPE:
2150Sstevel@tonic-gate if (flgm) {
2160Sstevel@tonic-gate /* suppress if message-type argument */
2170Sstevel@tonic-gate n = 0;
2180Sstevel@tonic-gate }
2190Sstevel@tonic-gate break;
2200Sstevel@tonic-gate case H_CONT:
2210Sstevel@tonic-gate if (oldn == 0) {
2220Sstevel@tonic-gate /* suppress continuation line also */
2230Sstevel@tonic-gate n = 0;
2240Sstevel@tonic-gate }
2250Sstevel@tonic-gate break;
2260Sstevel@tonic-gate }
2270Sstevel@tonic-gate oldn = n; /* remember if this line was suppressed */
2285387Sny155746 if (n && !wtmpf(line, n)) {
2290Sstevel@tonic-gate done(0);
2300Sstevel@tonic-gate }
2310Sstevel@tonic-gate if (!n) savehdrs(line, hdrtyp);
2320Sstevel@tonic-gate }
2330Sstevel@tonic-gate if (Rpath[0] != '\0') {
2340Sstevel@tonic-gate strcat(Rpath, "!");
2350Sstevel@tonic-gate }
2360Sstevel@tonic-gate (void) strlcat(Rpath, fromU, sizeof (Rpath));
2370Sstevel@tonic-gate
2380Sstevel@tonic-gate /* push out message type if so requested */
2390Sstevel@tonic-gate if (flgm) { /* message-type */
2405387Sny155746 snprintf(buf, sizeof (buf), "%s%s\n",
2415387Sny155746 header[H_MTYPE].tag, msgtype);
2420Sstevel@tonic-gate if (!wtmpf(buf, strlen(buf))) {
2430Sstevel@tonic-gate done(0);
2440Sstevel@tonic-gate }
2450Sstevel@tonic-gate }
2460Sstevel@tonic-gate
2475387Sny155746 memcpy(buf, line, n);
2485387Sny155746 if (n == 0 || (ttyf && !strncmp(buf, ".\n", 2))) {
2490Sstevel@tonic-gate if (flgf) {
2500Sstevel@tonic-gate /* no input */
2510Sstevel@tonic-gate return;
2520Sstevel@tonic-gate } else {
2530Sstevel@tonic-gate /*
2540Sstevel@tonic-gate * no content: put mime-version, content-type
2550Sstevel@tonic-gate * and -length only if explicitly present.
2560Sstevel@tonic-gate * Write out 'place-holders' only. (see below....)
2570Sstevel@tonic-gate */
2580Sstevel@tonic-gate if ((hptr = hdrlines[H_MIMEVERS].head) !=
2590Sstevel@tonic-gate (struct hdrs *)NULL) {
2605387Sny155746 (void) snprintf(line, sizeof (line), "%s \n",
2615387Sny155746 header[H_MIMEVERS].tag);
2620Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
2630Sstevel@tonic-gate done(0);
2640Sstevel@tonic-gate }
2650Sstevel@tonic-gate }
2660Sstevel@tonic-gate if ((hptr = hdrlines[H_CTYPE].head) !=
2670Sstevel@tonic-gate (struct hdrs *)NULL) {
2685387Sny155746 (void) snprintf(line, sizeof (line), "%s \n",
2695387Sny155746 header[H_CTYPE].tag);
2700Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
2710Sstevel@tonic-gate done(0);
2720Sstevel@tonic-gate }
2730Sstevel@tonic-gate }
2740Sstevel@tonic-gate if ((hptr = hdrlines[H_CLEN].head) !=
2750Sstevel@tonic-gate (struct hdrs *)NULL) {
2765387Sny155746 (void) snprintf(line, sizeof (line), "%s \n",
2775387Sny155746 header[H_CLEN].tag);
2780Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
2790Sstevel@tonic-gate done(0);
2800Sstevel@tonic-gate }
2810Sstevel@tonic-gate }
2820Sstevel@tonic-gate goto wrapsend;
2830Sstevel@tonic-gate }
2840Sstevel@tonic-gate }
2850Sstevel@tonic-gate
2860Sstevel@tonic-gate if (n == 1 && last1c == '\n') { /* blank line -- suppress */
287*13093SRoger.Faulkner@Oracle.COM n = getaline(buf, sizeof (buf), stdin);
2885387Sny155746 if (n == 0 || (ttyf && !strncmp(buf, ".\n", 2))) {
2890Sstevel@tonic-gate /*
2900Sstevel@tonic-gate * no content: put mime-version, content-type
2910Sstevel@tonic-gate * and -length only if explicitly present.
2920Sstevel@tonic-gate * Write out 'place-holders' only. (see below....)
2930Sstevel@tonic-gate */
2940Sstevel@tonic-gate if ((hptr = hdrlines[H_MIMEVERS].head) !=
2950Sstevel@tonic-gate (struct hdrs *)NULL) {
2965387Sny155746 (void) snprintf(line, sizeof (line), "%s \n",
2975387Sny155746 header[H_MIMEVERS].tag);
2980Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
2990Sstevel@tonic-gate done(0);
3000Sstevel@tonic-gate }
3010Sstevel@tonic-gate }
3020Sstevel@tonic-gate if ((hptr = hdrlines[H_CTYPE].head) !=
3030Sstevel@tonic-gate (struct hdrs *)NULL) {
3045387Sny155746 (void) snprintf(line, sizeof (line), "%s \n",
3055387Sny155746 header[H_CTYPE].tag);
3060Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
3070Sstevel@tonic-gate done(0);
3080Sstevel@tonic-gate }
3090Sstevel@tonic-gate }
3100Sstevel@tonic-gate if ((hptr = hdrlines[H_CLEN].head) !=
3110Sstevel@tonic-gate (struct hdrs *)NULL) {
3125387Sny155746 (void) snprintf(line, sizeof (line), "%s \n",
3135387Sny155746 header[H_CLEN].tag);
3140Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
3150Sstevel@tonic-gate done(0);
3160Sstevel@tonic-gate }
3170Sstevel@tonic-gate }
3180Sstevel@tonic-gate goto wrapsend;
3190Sstevel@tonic-gate }
3200Sstevel@tonic-gate }
3210Sstevel@tonic-gate
3220Sstevel@tonic-gate if (debug > 0) {
3230Sstevel@tonic-gate buf[n] = '\0';
3245387Sny155746 Dout(pn, 0, "header scan complete, readahead %d = \"%s\"\n",
3255387Sny155746 n, buf);
3260Sstevel@tonic-gate }
3270Sstevel@tonic-gate
3285387Sny155746 /*
3295387Sny155746 * Write out H_MIMEVERS, H_CTYPE & H_CLEN lines. These are used only as
3300Sstevel@tonic-gate * placeholders in the tmp file. When the 'real' message is sent,
3310Sstevel@tonic-gate * the proper values will be put out by copylet().
3320Sstevel@tonic-gate */
3330Sstevel@tonic-gate (void) snprintf(line, sizeof (line), "%s \n", header[H_MIMEVERS].tag);
3340Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
3350Sstevel@tonic-gate done(0);
3360Sstevel@tonic-gate }
3370Sstevel@tonic-gate if (hdrlines[H_MIMEVERS].head == (struct hdrs *)NULL) {
3380Sstevel@tonic-gate savehdrs(line, H_MIMEVERS);
3390Sstevel@tonic-gate }
3400Sstevel@tonic-gate (void) snprintf(line, sizeof (line), "%s \n", header[H_CTYPE].tag);
3410Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
3420Sstevel@tonic-gate done(0);
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate if (hdrlines[H_CTYPE].head == (struct hdrs *)NULL) {
3455387Sny155746 savehdrs(line, H_CTYPE);
3460Sstevel@tonic-gate }
3470Sstevel@tonic-gate (void) snprintf(line, sizeof (line), "%s \n", header[H_CLEN].tag);
3480Sstevel@tonic-gate if (!wtmpf(line, strlen(line))) {
3490Sstevel@tonic-gate done(0);
3500Sstevel@tonic-gate }
3510Sstevel@tonic-gate if (hdrlines[H_CLEN].head == (struct hdrs *)NULL) {
3525387Sny155746 savehdrs(line, H_CLEN);
3530Sstevel@tonic-gate }
3540Sstevel@tonic-gate /* and a blank line */
3550Sstevel@tonic-gate if (!wtmpf("\n", 1)) {
3560Sstevel@tonic-gate done(0);
3570Sstevel@tonic-gate }
3580Sstevel@tonic-gate Dout(pn, 0, "header out completed\n");
3590Sstevel@tonic-gate
3600Sstevel@tonic-gate pushrest = 0;
3610Sstevel@tonic-gate count = 0L;
3620Sstevel@tonic-gate /*
3630Sstevel@tonic-gate * Are we returning mail from a delivery failure of an old-style
3640Sstevel@tonic-gate * (SVR3.1 or SVR3.0) rmail? If so, we won't return THIS on failure
3650Sstevel@tonic-gate * [This line should occur as the FIRST non-blank non-header line]
3660Sstevel@tonic-gate */
3675387Sny155746 if (!strncmp("***** UNDELIVERABLE MAIL sent to", buf, 32)) {
3685387Sny155746 dflag = 9; /* 9 says do not return on failure */
3695387Sny155746 Dout(pn, 0, "found old-style UNDELIVERABLE line. dflag = 9\n");
3700Sstevel@tonic-gate }
3710Sstevel@tonic-gate
3720Sstevel@tonic-gate /* scan body of message */
3730Sstevel@tonic-gate while (n > 0) {
3745387Sny155746 if (ttyf && !strcmp(buf, ".\n"))
3750Sstevel@tonic-gate break;
3760Sstevel@tonic-gate if (!binflg) {
3775387Sny155746 binflg = !istext((unsigned char *)buf, n);
3780Sstevel@tonic-gate }
3790Sstevel@tonic-gate
3800Sstevel@tonic-gate if (!wtmpf(buf, n)) {
3810Sstevel@tonic-gate done(0);
3820Sstevel@tonic-gate }
3830Sstevel@tonic-gate count += n;
3840Sstevel@tonic-gate n = ttyf
385*13093SRoger.Faulkner@Oracle.COM ? getaline(buf, sizeof (buf), stdin)
3865387Sny155746 : fread(buf, 1, sizeof (buf), stdin);
3870Sstevel@tonic-gate }
3880Sstevel@tonic-gate setsig(SIGINT, saveint);
3890Sstevel@tonic-gate
3900Sstevel@tonic-gate wrapsend:
3910Sstevel@tonic-gate /*
3920Sstevel@tonic-gate * In order to use some of the subroutines that are used to
3930Sstevel@tonic-gate * read mail, the let array must be set up
3940Sstevel@tonic-gate */
3950Sstevel@tonic-gate nlet = 1;
3960Sstevel@tonic-gate let[0].adr = 0;
3970Sstevel@tonic-gate let[1].adr = ftell(tmpf);
3980Sstevel@tonic-gate let[0].text = (binflg == 1 ? FALSE : TRUE);
3990Sstevel@tonic-gate Dout(pn, 0, "body copy complete, count %ld\n", count);
4000Sstevel@tonic-gate /*
4010Sstevel@tonic-gate * Modify value of H_MIMEVERS if necessary.
4020Sstevel@tonic-gate */
4030Sstevel@tonic-gate if ((hptr = hdrlines[H_MIMEVERS].head) != (struct hdrs *)NULL) {
4040Sstevel@tonic-gate if (strlen(hptr->value) == 0) {
4050Sstevel@tonic-gate (void) strlcpy(hptr->value, "1.0",
4060Sstevel@tonic-gate sizeof (hptr->value));
4070Sstevel@tonic-gate }
4080Sstevel@tonic-gate }
4090Sstevel@tonic-gate /*
4100Sstevel@tonic-gate * Modify value of H_CTYPE if necessary.
4110Sstevel@tonic-gate */
4120Sstevel@tonic-gate if ((hptr = hdrlines[H_CTYPE].head) != (struct hdrs *)NULL) {
4130Sstevel@tonic-gate if (strlen(hptr->value) == 0) {
4140Sstevel@tonic-gate (void) strlcpy(hptr->value, "text/plain",
4150Sstevel@tonic-gate sizeof (hptr->value));
4160Sstevel@tonic-gate }
4170Sstevel@tonic-gate }
4180Sstevel@tonic-gate /*
4190Sstevel@tonic-gate * Set 'place-holder' value of content length to true value
4200Sstevel@tonic-gate */
4210Sstevel@tonic-gate if ((hptr = hdrlines[H_CLEN].head) != (struct hdrs *)NULL) {
4220Sstevel@tonic-gate (void) snprintf(hptr->value, sizeof (hptr->value),
4230Sstevel@tonic-gate "%ld", count);
4240Sstevel@tonic-gate }
4250Sstevel@tonic-gate
4260Sstevel@tonic-gate if (fclose(tmpf) == EOF) {
4270Sstevel@tonic-gate tmperr();
4280Sstevel@tonic-gate done(0);
4290Sstevel@tonic-gate }
4300Sstevel@tonic-gate
4315387Sny155746 tmpf = doopen(lettmp, "r+", E_TMP);
4320Sstevel@tonic-gate
4330Sstevel@tonic-gate /* Do not send mail on SIGINT */
4340Sstevel@tonic-gate if (dflag == 2) {
4350Sstevel@tonic-gate done(0);
4360Sstevel@tonic-gate }
4370Sstevel@tonic-gate
4380Sstevel@tonic-gate sendlist(&list, 0, 0);
4390Sstevel@tonic-gate done(0);
4400Sstevel@tonic-gate }
441