1 /*-
2 * Copyright (c) 1985, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)mailst.c 8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11
12 #include <signal.h>
13 #include "uucp.h"
14 #ifdef USG
15 #include <fcntl.h>
16 #endif USG
17
18 /*LINTLIBRARY*/
19
20 /*
21 * mailst - this routine will fork and execute
22 * a mail command sending string (str) to user (user).
23 * If file is non-null, the file is also sent.
24 * (this is used for mail returned to sender.)
25 */
26
mailst(user,str,file)27 mailst(user, str, file)
28 char *user, *str, *file;
29 {
30 register FILE *fp, *fi;
31 FILE *popen();
32 char buf[BUFSIZ];
33 register int c;
34
35 sprintf(buf, "IFS=\" \t\n\";%s '%s'", MAIL, user);
36 if ((fp = popen(buf, "w")) != NULL) {
37 fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
38 if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
39 while ((c = getc(fi)) != EOF)
40 putc(c, fp);
41 putc('\n', fp);
42 fclose(fi);
43 }
44 pclose(fp);
45 }
46 }
47