#!/usr/bin/perl # use CGI ; $q = new CGI; $destination = $q -> param ( 'destination' ); $sender = $q -> param ( 'sender' ); $name = $q -> param ( 'name' ); $link = $q -> param ( 'link' ); $nameofrecipe = $q -> param ( 'nameofrecipe' ); $openinghtml="/home/sites/www.koegelmeats.com/web/recipes/template.shtml"; ##### Begin Template Script ##### if (-e "$openinghtml"){ $problem="Can't open template file. Make sure you are referencing the file and not just a directory."; open(OPENING, "$openinghtml") || &security; @wholefile=; close(OPENING); $fulltemplate=join("\n",@wholefile); ($templatestart,$templateend)=split(/\+\+\+/,$fulltemplate);} else{ $templatestart="Koegel Meats"; $templateend="";} ##### End Template Script ##### ##### Begin Error Trap ####### $errmsg = "
  • Please enter a valid email address for the desination
  • \n" ; if ($destination !~ /.+\@.+\..+/) { $message = $message.$errmsg ; $found_err = 1 ; } $errmsg = "
  • Please enter a valid email address for yourself
  • \n" ; if ($sender !~ /.+\@.+\..+/) { $message = $message.$errmsg ; $found_err = 1 ; } $errmsg = "
  • Please enter your name
  • \n" ; if ($name eq '') { $message = $message.$errmsg ; $found_err = 1 ; } if ($found_err) { &PrintError; } ##### End Error Trap ####### ############################ ## OUTPUT ERROR MESSAGE ## ############################ sub PrintError { print "Content-type: text/html\n\n"; print<<"error1"; $templatestart

    EMAIL ADDRESS ERROR

    Error(s) Encountered:
    error1 print "$message \n"; print<<"error2";







    $templateend error2 exit 0 ; return 1 ; } ##### Begin Mailing ####### $mailprog = "/usr/sbin/sendmail"; open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n"; print MAIL "From: $sender($name)\n"; print MAIL "To: $destination\n"; print MAIL "Subject: Koegel's $nameofrecipe Recipe\n\n"; print MAIL " Check out http://www.koegelmeats.com/recipes/item.cgi?$link They have a delicious recipe for $nameofrecipe. The best part is the recipes on there aren't just submitted by experienced Chefs...they're submitted by average people like us! Check it out, you'll love it! $name \n"; close (MAIL); print "Content-type: text/html\n\n"; print " $templatestart

    Your email has been successfully sent to $destination

    Thank you, $name, for visiting KoegelMeats.com. $templateend \n"; exit; ##### End Mailing #######