- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main ()
{
char address[128], fname[128], command[128];
FILE *tempfile;
strcpy(fname , tmpnam(NULL));
tempfile = fopen (fname, "w"); /* create temporary file */
if (tempfile == NULL) /* error - didn't create file */
{
printf("Internal failure #1 please report %d\n", errno);
exit (1);
}
fprintf(tempfile, "Thank you very much for caring about our cause\n");
fprintf(tempfile, "this letter is just to tell you how much we\n");
fprintf(tempfile, "really think you are wonderful for caring.\n\n");
fprintf(tempfile, "Sincerely,\n\n");
fprintf(tempfile, "Jane Doe, Executive Thanker\n");
fclose (tempfile);
gets(address); /* read in email address */
sprintf(command, "mail -s \"thanks for caring\" %s < %s\n",
address, fname); /* create the command */
system (command); /* execute command */
remove (fname); /* clean up */
exit (0);
}