148652Sbostic /*-
2*62386Sbostic * Copyright (c) 1985, 1993
3*62386Sbostic * The Regents of the University of California. All rights reserved.
448652Sbostic *
548652Sbostic * %sccs.include.proprietary.c%
648652Sbostic */
748652Sbostic
813662Ssam #ifndef lint
9*62386Sbostic static char sccsid[] = "@(#)mailst.c 8.1 (Berkeley) 06/06/93";
1048652Sbostic #endif /* not lint */
1113662Ssam
1223612Sbloom #include <signal.h>
1313662Ssam #include "uucp.h"
1423612Sbloom #ifdef USG
1523612Sbloom #include <fcntl.h>
1623612Sbloom #endif USG
1713662Ssam
1823612Sbloom /*LINTLIBRARY*/
1923612Sbloom
2017835Sralph /*
2113662Ssam * mailst - this routine will fork and execute
2213662Ssam * a mail command sending string (str) to user (user).
2313662Ssam * If file is non-null, the file is also sent.
2413662Ssam * (this is used for mail returned to sender.)
2513662Ssam */
2613662Ssam
mailst(user,str,file)2713662Ssam mailst(user, str, file)
2813662Ssam char *user, *str, *file;
2913662Ssam {
3013662Ssam register FILE *fp, *fi;
3133953Srick FILE *popen();
3217835Sralph char buf[BUFSIZ];
3317835Sralph register int c;
3413662Ssam
3533953Srick sprintf(buf, "IFS=\" \t\n\";%s '%s'", MAIL, user);
3633953Srick if ((fp = popen(buf, "w")) != NULL) {
3717835Sralph fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
3817835Sralph if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
3917835Sralph while ((c = getc(fi)) != EOF)
4017835Sralph putc(c, fp);
4117835Sralph putc('\n', fp);
4217835Sralph fclose(fi);
4317835Sralph }
4433953Srick pclose(fp);
4513662Ssam }
4613662Ssam }
47