xref: /csrg-svn/usr.bin/uucp/libuu/mailst.c (revision 18620)
113662Ssam #ifndef lint
2*18620Sralph static char sccsid[] = "@(#)mailst.c	5.4 (Berkeley) 04/10/85";
313662Ssam #endif
413662Ssam 
513662Ssam #include "uucp.h"
613662Ssam 
717835Sralph /*
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;
1817835Sralph 	char buf[BUFSIZ];
1917835Sralph 	register int c;
2013662Ssam 
21*18620Sralph 	sprintf(buf, "%s '%s'", MAIL, user);
2217835Sralph 	if ((fp = rpopen(buf, "w")) != NULL) {
2317835Sralph 		fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
2417835Sralph 		if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
2517835Sralph 			while ((c = getc(fi)) != EOF)
2617835Sralph 				putc(c, fp);
2717835Sralph 			putc('\n', fp);
2817835Sralph 			fclose(fi);
2917835Sralph 		}
3017835Sralph 		rpclose(fp);
3113662Ssam 	}
3213662Ssam }
33