twm, I think you're getting confused about who posted.
twm, I think you're getting confused about who posted.
>twm, I think you're getting confused about who posted.
How so? The first part was to you, the second to RoshanX. As far as I can tell, each comment was sent to the proper person.
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
Nope , won't work. It will work if I use "Mail" instead of "mail". And I am using a sun os.
try doing something like:
I'm not sure if you need the newline or if it's best to use it there, but it should work.Code:... pipe_id=popen(mail_command,"w"); fprintf(pipe_id,"Subject: %s\n",subject); //subject placed here for(j=0;j<i;j++) { fprintf(pipe_id,"%s",list[j]); } fprintf(pipe_id,"%c",EOF); ...
This is a tad late, but you could always do something like this (to solve the discrepency about "mail" and "Mail" :P)
Not the best way, but it works, and I know, I had to use system()Code:#define YourEmail "[email protected]" FILE *email; char cmd[64] = ""; if((email = fopen("mail", "a+")) == NULL) die("Cannot open text file for email.\n"); fprintf(email, "To: %s\n", recpt); fprintf(email, "From: %s\n", YourEmail); fprintf(email, "Subject: There are %d users using %d processes\n\n", user_count, proc_count); /* ** fprintf(email, "message line here\n"); ** etc */ fclose(email); sprintf(cmd, "/usr/lib/sendmail %s < mail", recpt); system(cmd);
I'm sure there are other ways, such as "fastmail", or "sendmail -t with popen() and pclose()", but like I said, this was just an idea I had and decided to post because of the "mail" "Mail" discussion and to show that the code for it isn't that long in C, as the other person suggested.
- Daniel Wallace