xref: /csrg-svn/usr.bin/uucp/libuu/mailst.c (revision 33953)
113662Ssam #ifndef lint
2*33953Srick static char sccsid[] = "@(#)mailst.c	5.7	(Berkeley) 04/05/88";
313662Ssam #endif
413662Ssam 
523612Sbloom #include <signal.h>
613662Ssam #include "uucp.h"
723612Sbloom #ifdef USG
823612Sbloom #include <fcntl.h>
923612Sbloom #endif USG
1013662Ssam 
1123612Sbloom /*LINTLIBRARY*/
1223612Sbloom 
1317835Sralph /*
1413662Ssam  *	mailst  -  this routine will fork and execute
1513662Ssam  *	a mail command sending string (str) to user (user).
1613662Ssam  *	If file is non-null, the file is also sent.
1713662Ssam  *	(this is used for mail returned to sender.)
1813662Ssam  */
1913662Ssam 
2013662Ssam mailst(user, str, file)
2113662Ssam char *user, *str, *file;
2213662Ssam {
2313662Ssam 	register FILE *fp, *fi;
24*33953Srick 	FILE *popen();
2517835Sralph 	char buf[BUFSIZ];
2617835Sralph 	register int c;
2713662Ssam 
28*33953Srick 	sprintf(buf, "IFS=\" \t\n\";%s '%s'", MAIL, user);
29*33953Srick 	if ((fp = popen(buf, "w")) != NULL) {
3017835Sralph 		fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
3117835Sralph 		if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
3217835Sralph 			while ((c = getc(fi)) != EOF)
3317835Sralph 				putc(c, fp);
3417835Sralph 			putc('\n', fp);
3517835Sralph 			fclose(fi);
3617835Sralph 		}
37*33953Srick 		pclose(fp);
3813662Ssam 	}
3913662Ssam }
40