I have a Perl subroutine called from a CGI I call deliver.  It was designed
to deliver quarantined messages to whatever location I desired.  Although I
call a file to create a message array in which I pass the reference $msgref,
you could just create the array from the form.  The RCPT TO array is also
passed as a reference so you can either read a file or create a message box
to allow for multiple recipients.  It prints an echo of the commands sent
but not the data.

I used the perl-MailTools module.  It really needs IO::Socket.  Nothing
mystical here and it should allow you some flexibility.

Hope it helps.

--Larry


> -----Original Message-----
> From: Evan Platt [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 09, 2003 4:05 PM
> To: SpamAssassin
> Subject: [SAtalk] OT Help: Mail form CGI script?
> 
> 
> I'm in need of a decent CGI script, easily implementable by a 
> somewhat rookie web designer.. What I'm looking for is a web 
> site that has a form, someone fills out the form, and it 
> e-mails the contents of the form to a list of e-mail 
> addresses. Essentially, it's for a volunteer fire department, 
> we get a call and put the details in the form, and it alerts 
> the volunteers cell phones. I have a form now, however it 
> does a TO: command, and now since there's about 30 
> recipients, some of the systems are starting to reject the 
> message (too many recipients). 
> 
> Any suggestions? 
> 
> I do have a Win XP box at home running a dynamic DNS so I can 
> put a mail software on that, simply have it forward the message....
> 
> but if any mailserver does a reverse DNS, I'm hosed.
> 
> Thanks.
> 
> :)

##############################################################
########## Quarantine Delivery ##### deliver.cgi #############
##############################################################
sub deliver_mail
{
   use IO::Socket;

   my ($remotehost, $localhost, $from, $toref, $msgref) = @_;

   my $remote = IO::Socket::INET->new(Proto    => "tcp",
                                      PeerAddr => $remotehost,
                                      PeerPort => "25") or die $!;

   $_ = <$remote>;  print;
   if (/^220/) {
      print "<br>";
      print "<b>HELO $localhost</b><br>";
      print $remote "HELO $localhost\n";
      $_ = <$remote>;  print;
      if (/^250/) {
         print "<b>MAIL FROM: "  . &html_escape($from) . "</b><br>";
         print $remote "MAIL FROM: $from\n";
         $_ = <$remote>;  print;
         if (/^250/) {
            foreach $to ( @{$toref} ) {
               print "<b>RCPT TO: "  . &html_escape($to) . "</b><br>";
               print $remote "RCPT TO: $to\n";
               $_ = <$remote>;  print;
            }
            if (/^250/) {
               print "<b>DATA</b><br>";
               print $remote "DATA\n";
               $_ = <$remote>;  print;
               print "<b>Sending DATA . . .</b><br>";
               if (/^354/) {
                  foreach $line ( @{$msgref} )
                  {
                     print $remote $line;
                  }
                  print "<b>.</b><br>";
                  print $remote ".\n";
                  $_ = <$remote>;  print;
                  if (/^250/) {
                     print "<b>QUIT</b><br>";
                     print $remote "QUIT\n";
                     $_ = <$remote>;  print;
                     if (/^221/) {
                        close $remote;
                        print "&nbsp<br>";
                        print "$fullpath was delivered!<br>";
                     }#Close and Print
                  }#QUIT
               }#MSG
            }#DATA
         }#RCPT TO
      }#MAIL FROM
   }HELO
}

Reply via email to