From: Prashant TR
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Pipe to sendmail (like Perl)
Date: 02 Jul 2000 23:49:44 +0530
Organization: VSNL
Lines: 36
Message-ID:
References:
NNTP-Posting-Host: ppp-181-218.bng.vsnl.net.in
X-Trace: news.vsnl.net.in 962599345 26621 203.197.181.218 (3 Jul 2000 04:42:25 GMT)
X-Complaints-To: postmaster AT news DOT vsnl DOT net DOT in
NNTP-Posting-Date: 3 Jul 2000 04:42:25 GMT
X-Newsreader: Gnus v5.7/Emacs 20.5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
"Olaf van der Spek" writes:
> I try to use a C++ program to send a mail using sendmail on a Unix server.
> In Perl, you can use this:
> $mailprog = '/usr/sbin/sendmail';
> open (MAIL, "|$mailprog $in{'address'}") || die "Can't open
> $mailprog!\n";
> print MAIL "From: $admin_email\n";
> print MAIL "Subject: You are added!\n\n";
> print MAIL < This is to confirm your addition to the $list_name.
> to_the_end
>
> So in C++, I tried:
> void send_mail(const string& from, const string& to, const string& subject,
> const string& body)
> {
> ofstream mail;
> mail.open("|/usr/sbin/sendmail -oi -t");
> if (!mail.is_open())
> cout << "Can't open pipe to sendmail" << endl;
> mail << "To: " << to << endl
> << "From: " << from << endl
> << "Subject: " << subject << endl
> << body;
> }
>
> But that didn't work, I got the error "Can't open pipe to sendmail".
> Anybody knows how this could be solved?
This is the wrong newsgroup. Please try
comp.os.linux.development.apps, comp.lang.perl.misc
--
Prashant TR
Web: http://www.midpec.com/