#!@PERL@
$rcsid = q$Id: w3mmail.cgi.in,v 1.1 2002/01/15 05:36:24 ukai Exp $;
($id = $rcsid) =~ s/^.*,v ([\d\.]*).*/$1/;
($prog=$0) =~ s/.*\///;
$query = $ENV{'QUERY_STRING'};
$url = $query;
$SENDMAIL = '/usr/lib/sendmail';
$SENDMAIL = '/usr/sbin/sendmail' if -x '/usr/sbin/sendmail';
$qurl = &html_quote($url);
if ($query =~ s/^\w+://) {
$to = $query;
$opt = '';
if ($to =~ /^([^?]*)\?(.*)$/) {
$to = $1;
$opt = $2;
}
%opt = &parse_opt($opt);
@to = ($to);
push(@to, $opt{'to'}) if ($opt{'to'});
$opt{'to'} = join(',', @to);
$body = $opt{'body'};
delete $opt{'body'};
print "200 HTTP/1.0 OK\r\n";
print "Content-Type: text/html\r\n";
print "w3m-control: END\r\n";
print "w3m-control: PREV_LINK\r\n";
print "\r\n";
print "
W3M Mailer: $qurl\n";
print "W3M Mailer: $qurl
\n";
print "\n";
print "\n";
exit(0);
} else {
print "200 HTTP/1.0 OK\r\n";
sysread(STDIN, $req, $ENV{'CONTENT_LENGTH'});
%opt = &parse_opt($req);
$body = &html_quote($opt{'body'});
delete $opt{'body'};
$act = $opt{'action'};
delete $opt{'action'};
&lang_setup;
if ($act eq "preview") {
print "Content-Type: text/html\r\n";
print "w3m-control: NEXT_LINK\r\n";
print "\r\n";
print "W3M Mailer\n";
print "\n";
print "W3M Mailer: preview
\n";
print "