Mail Archives: djgpp/2000/07/10/02:38:20
On Sun, 9 Jul 2000, Olaf van der Spek wrote:
> I tried the following code with g++ on a Unix Apache server.
> #include <cstdio>
> #include <cstdlib>
> #include <iostream>
>
> int main()
> {
> FILE* mail = popen("/usr/sbin/sendmail", "tw");
> cout // << errno << endl
> << mail << endl;
> return 0;
> }
>
> The errno is commented because g++ complained about an undeclared
> identifier.
> I get NULL as result, meaning the pipe couldn't get opened.
`sendmail' must have at least one address on its command line,
otherwise it won't know where to send the message.
Also note that you need to call `pclose'. It's quite possible that,
since you only write a few characters to the pipe, without `pclose'
those characters are buffered somewhere and don't get delivered to
`sendmail' at all.
- Raw text -