#!/usr/bin/perl #======================================================# # EveryAuction Addon # Send mail to all users v1.0 #------------------------------------------------------# # This is a stand alone script that will send an email # message to all of your registered users. #======================================================# # PiTA - Park In The Alley Software (Auction-Script.com) #======================================================# # Author: Splatt 10/26/99 # justguns.com auction-script.com compalley.com #------------------------------------------------------# # Unauthorized redistribution is prohibited!!! # The latest version of my addons can be found at: # www.auction-script.com/addons #======================================================# #------------------------------------------------------# # Edit the configuration variables, these should be $ taken directly out of your auction.cgi script. # Then rename this file to mailtoall.cgi and place it # in your cgi-bin directoy. #------------------------------------------------------# # Call it via: mailtoall.cgi?mailtoall&password #------------------------------------------------------# #------------------------------------------------------# # Configuration settings (copy these out of auction.cgi) #------------------------------------------------------# $basepath = '/usr/cgi-bin/auction/'; $adminpass = 'auction'; $mailserver = "/usr/sbin/sendmail"; $regdir = 'reg'; $scripturl = "www.yourdomain.com"; $colorbg = '#FFFFFF'; $colortext = '#000000'; $colorlink = '#000080'; $colorvlink = '#408080'; $coloralink = '#800080'; $colortablehead = '#BECEFA'; $colortableheadtwo ='#80BFBF'; $colortablebody = '#EEEEEE'; $sitename = 'Your Site'; $mailfrom = "Your Site "; #------------------------------------------------------# # End configuration #------------------------------------------------------# #------------------------------------------------------# # Main code #------------------------------------------------------# print "Content-type: text/html\n\n"; print "$sitename - eMail all users"; &get_form_data; @ARGV = split(/\\*\&/, $ENV{'QUERY_STRING'}); $ARGV[0] =~ s/\W//g; if (($ARGV[0] eq 'mailtoall') && ($ARGV[1] eq $adminpass)) { &mailtoall; } if ($form{'action'} eq 'mailtoall') { &mailtoallsend; } #------------------------------------------------------# # Sub: Form input for email message #------------------------------------------------------# sub mailtoall { #------------------------------------------------------# print "
"; print ""; print ""; print ""; print "
Send an eMail to ALL users
"; print ""; print "
"; print "
\n"; print "\n"; print "
"; print ""; print "
Administration is required for this procedure!
\n"; print ""; print "\n"; print ""; print "\n"; print "
Administration Password:
Must be valid.
Message:
Message to send to users
"; print "
\n"; } #------------------------------------------------------# # Sub: Mail Auction To All Users # This sub checks the password and sends the mail # By: Splatt #------------------------------------------------------# sub mailtoallsend { #------------------------------------------------------# &oops('incorrect password') unless ((lc $form{'PASSWORD'}) eq (lc $adminpass)); $mailto1 = " Hello, This is an administrative message from $sitename: $form{'MESSAGE'} Thank you and please tell a friend about us! Sincerely, $sitename "; opendir THEDIR, "$basepath$regdir" || die "Unable to open directory: $!"; @allfiles = readdir THEDIR; closedir THEDIR; foreach $file (sort { int($a) <=> int($b) } @allfiles) { if (-T "$basepath$regdir/$file") { open REGFILE, "$basepath$regdir/$file"; ($password,$email,$add1,$add2,$add3,@junk) = ; chomp($password,$email,$add1,$add2,$add3,@junk); close REGFILE; } &sendemail($email,"$sitename Message", 'nobody', $mailserver, $mailto1); sleep 1; # give the server 1 second between sends print "Message sent to $email
"; } } #------------------------------------------------------# #------------------------------------------------------# # SUB: Send E-mail (ORIGINAL) # This is a real quick-and-dirty mailer that # should work on any platform. It is my first # attempt to work with sockets, so if anyone # has any suggestions, let me know! # # Takes: # (To, Subject, Reply-To, IP ADDRESS of SMTP host, Message) #------------------------------------------------------# #sub sendemail { #------------------------------------------------------# # use Socket; # $TO=$_[0]; @TO=split('\0',$TO); # $SUBJECT=$_[1]; # $REPLYTO=$_[2]; # $REMOTE = $_[3]; # $THEMESSAGE = $_[4]; # if ($REMOTE =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { # $addr = pack('C4', $1, $2, $3, $4); # } # else { die("Bad IP address: $!"); } # $port = 25 unless $port; # $port = getservbyname($port,'tcp') if $port =~ /\D/; # $proto = getprotobyname('tcp'); # socket(S, PF_INET, SOCK_STREAM, $proto) or die("Socket failed: $!"); # $sockaddr = 'S n a4 x8'; # shouldn't this be in Socket.pm? # connect(S, pack($sockaddr, AF_INET, $port, $addr)) or die("Unable to connect: $!"); # # select(S); $| = 1; select(STDOUT); # $a=; # print S "HELO ${SERVERNAME}\n"; # $a=; # #print S "MAIL FROM:\n"; # print S "MAIL FROM:$mailfrom\n"; # $a=; # print S "RCPT TO:<$TO[0]>\n"; # $a=; # if ($#TO > 0) { foreach (1..$#TO) { print S "RCPT TO: $TO[$_]\n";$a=; } # } # print S "DATA \n"; # $a=; # print S "To: $TO[0]\n"; # if ($#TO > 0) { foreach (1..$#TO) { print S "Cc: $TO[$_]\n"; } # } # print S "Subject: $SUBJECT\n"; # print S "Reply-To: $REPLYTO\n"; # # # Print the body # print S "$THEMESSAGE\n"; # print S ".\n"; # $a=; # print S "QUIT"; # close (S); #} #------------------------------------------------------# #------------------------------------------------------# # SUB: Send E-mail # UNIX Sendmail Version # Only use this if the built-in version does # not work. # # Takes: # (To, Subject, Reply-To, Mail Program (ie. sendmail), Message) #------------------------------------------------------# sub sendemail { #------------------------------------------------------# $TO=$_[0]; @TO=split('\0',$TO); $SUBJECT=$_[1]; $REPLYTO=$_[2]; $REMOTE = $_[3]; $THEMESSAGE = $_[4]; open(S, "|$REMOTE -t"); print S "To: $TO[0]\n"; print S "From: $mailfrom\n"; #print S "From: \n"; print S "Subject: $SUBJECT\n"; print S "Reply-To: $REPLYTO\n\n"; # Print the body print S "$THEMESSAGE\n"; print S "\n"; print S ".\n"; close (S); } #------------------------------------------------------# #------------------------------------------------------# # SUB: Send EMail uses sendmail.pm # Added this because original didn't work on NT # # Takes: # (To, Subject, Reply-To, IP ADDRESS of SMTP host, Message) #------------------------------------------------------# #sub sendemail { #------------------------------------------------------# # # use sendmail; # # $TO=$_[0]; @TO=split('\0',$TO); # $SUBJECT=$_[1]; # $REPLYTO=$_[2]; # $REMOTE = $_[3]; # $THEMESSAGE = $_[4]; # # $sm = new SendMail($mailserver); # $sm->setDebug($sm->OFF); # $sm->From($mailfrom); # $sm->Subject($SUBJECT); # $sm->To($TO[0]); # $sm->setMailBody($THEMESSAGE); # # if ($sm->sendMail() != 0) { # print $sm->{'error'}."MAIL ERROR!!\n"; # # exit -1; # # exit 0; # } # # print "\n\n"; # # exit 0; # return 0; #} #------------------------------------------------------# #------------------------------------------------------# # Sub: Get Form Data #------------------------------------------------------# sub get_form_data { #------------------------------------------------------# $buffer = ""; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$buffer); foreach $pair (@pairs) { @a = split(/=/,$pair); $name=$a[0]; $value=$a[1]; $value =~ s/\+/ /g; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/~!/ ~!/g; # $value =~ s/[\n\r]/ /sg; #remove \n $value =~ s/\[\]//g; #remove [] push (@data,$name); push (@data, $value); } %form=@data; %form; } #------------------------------------------------------#