xref: /csrg-svn/usr.bin/uucp/libuu/mailst.c (revision 17835)
113662Ssam #ifndef lint
2*17835Sralph static char sccsid[] = "@(#)mailst.c	5.3 (Berkeley) 01/22/85";
313662Ssam #endif
413662Ssam 
513662Ssam #include "uucp.h"
613662Ssam 
7*17835Sralph /*
813662Ssam  *	mailst  -  this routine will fork and execute
913662Ssam  *	a mail command sending string (str) to user (user).
1013662Ssam  *	If file is non-null, the file is also sent.
1113662Ssam  *	(this is used for mail returned to sender.)
1213662Ssam  */
1313662Ssam 
1413662Ssam mailst(user, str, file)
1513662Ssam char *user, *str, *file;
1613662Ssam {
1713662Ssam 	register FILE *fp, *fi;
18*17835Sralph 	char buf[BUFSIZ];
19*17835Sralph 	register int c;
2013662Ssam 
21*17835Sralph 	sprintf(buf, "%s %s", MAIL, user);
22*17835Sralph 	if ((fp = rpopen(buf, "w")) != NULL) {
23*17835Sralph 		fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
24*17835Sralph 		if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
25*17835Sralph 			while ((c = getc(fi)) != EOF)
26*17835Sralph 				putc(c, fp);
27*17835Sralph 			putc('\n', fp);
28*17835Sralph 			fclose(fi);
29*17835Sralph 		}
30*17835Sralph 		rpclose(fp);
3113662Ssam 	}
3213662Ssam }
33