OK, I forgot that I didn't use PHP, but I altered the formmail script to send out the mail. Formmail is very insecure, but if you use it right it can do no harm. You can use the script generater from TWebman:
http://twebman.lunarpages.com/perl/I used that script to create the sample code below, which I altered a bit to make it function correctly for subscribing to your maillist (I didn't test this!):
#!/usr/bin/perl
if ($ENV{'REQUEST_METHOD'} eq 'GET'){
print "Content-type:text/html\n\n";
print "Sorry, no GET methods allowed";exit(); }
if ($ENV{'QUERY_STRING'}){
print "Content-type: text/html\n\n";
print "Sorry, no query strings allowed";exit(); }
@referers=("yourdomain.com");
$check_referer = 0;
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|http?://([^/]*)$referer|i) {
$check_referer = 1;
last;}}} else{
$check_referer = 1;}
if ($check_referer != 1){
print "Content-type: text/html\n\n";
print "<p><b><font size=\"4\" face=\"Arial\">You are not authorized to use this script from $ENV{'HTTP_REFERER'}\n";exit();}
if ($ENV{'REQUEST_METHOD'} eq 'POST'){
read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);}
local($name, $value);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$gForm{$name} = $value;}
$sj="";
$fm="yourlist-request\@yourdomain.com";
if ($gForm{'email'} ne ""){
$fm=$gForm{'email'};}
if ($gForm{'Email'} ne ""){
$fm=$gForm{'Email'};}
open(MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: yourlist-request\@yourdomain.com\n";
print MAIL "From: $fm\n";
print MAIL "Subject: $sj\n";
print MAIL "--------------------------------------------------\n";
@pairs = split(/&/, $buffer);
local($name, $value);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
if ($name eq "L1"){next;}
if ($name eq "S1"){next;}
if ($name eq "Submit"){next;}
if ($name eq "submit"){next;}
$name =~ tr/+/ /;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$gForm{$name} = $value;
print MAIL "subscribe $fm\n";
close (MAIL);
print "location: $gForm{'L1'}\n\n";
sleep(1);
You'll need to change yourdomain.com to your own domain name, and
yourlist-request@yourdomain.com as well. The part "yourlist-request" is the name of your list with "-request" appended to it.
For instructions on how to upload this, go to
http://twebman.lunarpages.com/perl/pf2.php (fill in the two fields to get the instructions).
The form field in which the user enters his address must be named Email or email. If you want to let users unsubscribe through a script as well, you'll need to put
print MAIL "unsubscribe $fm\n";
instead of
print MAIL "subscribe $fm\n";
Also the approved message arrived to the test address with this in the From:News-bounces@(mydomain).com; on behalf of; news@(mydomain).com..what is that about?
The News-bounces means that undelivered messages are being handled by the mailman software instead of being delivered to your mailbox.
Any more questions? Don't hesitate to ask!
