[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cobalt-users] newbie to CGI + sendmail.
- Subject: RE: [cobalt-users] newbie to CGI + sendmail.
- From: "Clark E. Morgan" <prlhkr@xxxxxxxxxxxxx>
- Date: Sun Jan 7 21:58:01 2001
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
>
> Any one want to help me impliment a sendmail script on the qube?
>
Jason,
You don't say what you are looking for in terms of "engine"
so to speak; so here are the basics of doing it with perl as
that is pretty universal. You'll need to edit this for the
path to perl and for the path to sendmail. In your form, you
will need a minimum of three variables:
form_recipient
form_sender
form_subject
What they do is fairly obvious.
----------------------------------------------------------
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail';
print "Content-type: text/html\n\n";
if ($ENV{'REQUEST_METHOD'} eq "get") { $formstuff = $ENV{'QUERY_STRING'};}
else { read(STDIN, $formstuff, $ENV{'CONTENT_LENGTH'});
}
@pArrs = split(/&/, $formstuff);
foreach $pair (@pArrs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$recipient = $FORM{'form_recipient'};
format MAIL =
.
open (MAIL, "|$mailprog $recipient") || die "$mailprog not available.\n";
print MAIL "From: $FORM{'form_sender'},\n";
print MAIL "Subject: $FORM{'form_subject'}.\n\n";
foreach $pair (@nvpairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
print MAIL "$name = $value\n";
}
print MAIL "\n";
close (MAIL);
print "<HTML><HEAD><TITLE>Thanks</TITLE></HEAD><BODY>\n";
print "<H2 ALIGN=CENTER>Thank You</H2>\n";
--------------------------------------------------------------------
This stuff is quite a bit quicker with php if you've got that
up and running already.
Clark E. Morgan