httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ras...@lerdorf.on.ca (Rasmus Lerdorf)
Subject Re: CGIs in sendmail
Date Sat, 30 Aug 1997 14:00:43 GMT
> > Has anyone managed to write a CGI in sendmail macros?  I'm having trouble
> > finding a decent way to make it work without needing too much of a shell
> > script frontend to strip stuff off and add stuff to the output and input.
> 
> Using either mod_php or mod_perl you could just open a pipe directly to
> sendmail and fputs() things to it.  CGI is evil.

Ok, that probably didn't make much sense.  Here is an example to go along
with it.  The following tag set of tags in your HTML would do the trick:

    <?
        $fd = popen("/usr/lib/sendmail -t","w");
        fputs($fd, "To: $to\n");
        fputs($fd, "From: $from\n");
        fputs($fd, "Subject: Form Results\n");
        fputs($fd, "Reply-to: $from\n");
        $ver = phpversion();
        fputs($fd, "X-Mailer: PHP/FI $ver\n\n");
        fputs($fd, $body);
        pclose($fd)
    >

$to, $from and $body could come from a previous form which would have
fields with those names.  mod_php automatically converts fields to
variables.

There is also a Mail() function in mod_php which basically just does the
above.  

-Rasmus


Mime
View raw message