1*48652Sbostic /*- 2*48652Sbostic * Copyright (c) 1985 The Regents of the University of California. 3*48652Sbostic * All rights reserved. 4*48652Sbostic * 5*48652Sbostic * %sccs.include.proprietary.c% 6*48652Sbostic */ 7*48652Sbostic 813662Ssam #ifndef lint 9*48652Sbostic static char sccsid[] = "@(#)mailst.c 5.8 (Berkeley) 04/24/91"; 10*48652Sbostic #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 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