9 date 93.08.20.15.51.29; author jromine; state Exp;
14 date 92.12.15.00.20.22; author jromine; state Exp;
19 date 92.11.04.00.46.24; author jromine; state Exp;
24 date 92.10.27.00.13.21; author jromine; state Exp;
29 date 92.01.31.22.12.50; author jromine; state Exp;
34 date 92.01.31.05.51.11; author jromine; state Exp;
39 date 90.04.05.15.01.25; author sources; state Exp;
44 date 90.02.06.13.21.18; author sources; state Exp;
49 date 90.02.06.13.21.05; author sources; state Exp;
60 @added -queued to pass to post
63 @/* mhmail.c - simple mail program */
65 static char ident[] = "@@(#)$Id: mhmail.c,v 1.8 1992/12/15 00:20:22 jromine Exp jromine $";
77 static struct swit switches[] = {
103 static TYPESIG intrser ();
106 static char tmpfil[BUFSIZ];
136 setlocale(LC_ALL, "");
138 invo_name = r1bindex (argv[0], '/');
142 execlp (incproc, r1bindex (incproc, '/'), NULLCP);
143 adios (incproc, "unable to exec");
148 while (cp = *argp++) {
150 switch (smatch (++cp, switches)) {
152 ambigsw (cp, switches);
156 adios (NULLCP, "-%s unknown", cp);
159 (void) sprintf (buf, "%s [addrs ... [switches]]",
161 help (buf, switches);
165 if (!(from = *argp++) || *from == '-')
166 adios (NULLCP, "missing argument to %s", argp[-2]);
170 if (!(body = *argp++) || *body == '-')
171 adios (NULLCP, "missing argument to %s", argp[-2]);
179 if (!(subject = *argp++) || *subject == '-')
180 adios (NULLCP, "missing argument to %s", argp[-2]);
192 cclist = cclist ? add (cp, add (", ", cclist)) : getcpy (cp);
194 tolist = tolist ? add (cp, add (", ", tolist)) : getcpy (cp);
200 adios (NULLCP, "usage: %s addrs ... [switches]", invo_name);
201 (void) strcpy (tmpfil, m_tmpfil (invo_name));
202 if ((out = fopen (tmpfil, "w")) == NULL)
203 adios (tmpfil, "unable to write");
204 (void) chmod (tmpfil, 0600);
206 setsig (SIGINT, intrser);
208 fprintf (out, "%sTo: %s\n", resent ? "Resent-" : "", tolist);
210 fprintf (out, "%scc: %s\n", resent ? "Resent-" : "", cclist);
212 fprintf (out, "%sSubject: %s\n", resent ? "Resent-" : "", subject);
214 fprintf (out, "%sFrom: %s\n", resent ? "Resent-" : "", from);
216 (void) fputs ("\n", out);
219 fprintf (out, "%s", body);
220 if (*body && *(body + strlen (body) - 1) != '\n')
225 (i = fread (buf, sizeof *buf, sizeof buf, stdin)) > 0;
227 if (fwrite (buf, sizeof *buf, i, out) != i)
228 adios (tmpfil, "error writing");
230 (void) unlink (tmpfil);
239 vec[nvec++] = r1bindex (postproc, '/');
240 vec[nvec++] = tmpfil;
242 vec[nvec++] = "-dist";
244 vec[nvec++] = "-queued";
247 for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)
250 case NOTOK: /* report failure and then send it */
251 admonish (NULLCP, "unable to fork");
254 execvp (postproc, vec);
255 fprintf (stderr, "unable to exec ");
260 if (status = pidXwait (child_id, postproc)) {
261 fprintf (stderr, "Letter saved in dead.letter\n");
262 execl ("/bin/mv", "mv", tmpfil, "dead.letter", NULLCP);
263 execl ("/usr/bin/mv", "mv", tmpfil, "dead.letter", NULLCP);
268 (void) unlink (tmpfil);
269 done (status ? 1 : 0);
277 static TYPESIG intrser (i)
282 (void) signal (i, SIG_IGN);
285 (void) unlink (tmpfil);
286 done (i != 0 ? 1 : 0);
298 static char ident[] = "@@(#)$Id: mhmail.c,v 1.7 1992/11/04 00:46:24 jromine Exp jromine $";
309 execlp (postproc, r1bindex (postproc, '/'), tmpfil,
310 resent ? "-dist" : NULLCP, NULLCP);
322 static char ident[] = "@@(#)$Id: mhmail.c,v 1.6 1992/10/27 00:13:21 jromine Exp jromine $";
337 static char ident[] = "@@(#)$Id: mhmail.c,v 1.5 1992/01/31 22:12:50 jromine Exp jromine $";
341 static int intrser ();
345 static int intrser (i)
356 static char ident[] = "@@(#)$Id: mhmail.c,v 1.4 1992/01/31 05:51:11 jromine Exp jromine $";
365 @add -resent for mrose@@dbc.mtview.ca.us
370 static char ident[] = "@@(#)$Id: mhmail.c,v 1.3 1990/04/05 15:01:25 sources Exp jromine $";
384 static char ident[] = "@@(#)$Id:$";
390 fprintf (out, "To: %s\n", tolist);
393 fprintf (out, "cc: %s\n", cclist);
396 fprintf (out, "Subject: %s\n", subject);
399 fprintf (out, "From: %s\n", from);
400 (void) fputs ("\n", out);
403 execlp (postproc, r1bindex (postproc, '/'), tmpfil, NULLCP);