www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/10/02:38:20

Date: Mon, 10 Jul 2000 09:37:21 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Olaf van der Spek <Olaf AT XCC DOT TMFWeb DOT NL>
cc: djgpp AT delorie DOT com
Subject: Re: Pipe to sendmail (again)
In-Reply-To: <yG3a5.322335$k22.1427482@flipper>
Message-ID: <Pine.SUN.3.91.1000710093658.5255D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019