#!perl use strict; use warnings; # hacked together by Tim Musson 2002/06/05 # Updated 2002/10/25 use CGI qw/:standard/; my %eM; # define the hash my $Parms="-debug"; # other blat switches (blat with no parms) my $debug="yes"; # set this to 0 or "" to not print the 'if $debug' stuff # This bit creates the html form. # Comment lines you do not want. # If you do, don't forget to set variable in the #SetVars section print header, start_html('Perl CGI form to send eMail with Blat'), h1('Perl CGI form to send eMail with Blat'), start_form, "From: ",textfield('FromeMail'),p, "To: ",textfield('ToeMail'),p, "Subject: ",textfield('Subject'),p, "Message: ",textarea('Message'),p, submit('Send'),p, "SMTP Svr: ",textfield('SMTPServer'), end_form; if (param()) { # if any part of the form is filled out... my $form = new CGI; # setup to get the form info #SetVars # $eM{FmN}=$form->param('FromName'); $eM{FmE}=$form->param('FromeMail'); $eM{ToE}=$form->param('ToeMail'); $eM{Sbj}=$form->param('Subject'); $eM{Msg}=$form->param('Message'); $eM{Svr}=$form->param('SMTPServer'); # $eM{Svr}="smtp.your.server.here"; # uncomment this line if you comment the # 'SMTP Server to use' line above. # Lets, build the Blat command line to run! my $RunBlat="blat.exe - -to \"$eM{ToE}\" -subject \"$eM{Sbj}\" -f \"$eM{FmE}\" -body \"$eM{Msg}\" -server $eM{Svr} $Parms"; # Ok, everything is built, run Blat & send the message! my $BlatError=`$RunBlat`; # run blat, and put it's STDOUT in $BlatError # Now we print some output to the web page... # If you don't want part of it printed, just comment it. if ($debug) { print hr,"From eMail: ",b(param('FromeMail')),br, "To eMail: ",b(param('ToeMail')),p, "Subject: ",b(param('Subject')),p, "Message: ",b(param('Message')),p, "Using the ",b($eM{Svr})," mail server to send",hr, "$RunBlat" if $debug; # the 'if $debug' part allows us to turn on and off this # printing part with the $debug var at the top... # If there is anything in $debug, this prints. print hr,pre,"$BlatError" if $BlatError; # print the errors if they exist... } else { print <