sub SendMail { $smtp = Net::SMTP->new($mailserver); $smtp->mail ($ENV{USER}); $smtp->to($to); $smtp->data(); $smtp->datasend("To: Wheels and Deals \n"); $smtp->datasend("From: $client \n"); $smtp->datasend("Subject: $subject \n"); $smtp->datasend("\n"); $smtp->datasend("Ad Type $choice \n"); $smtp->datasend("Client Phone Number $phone \n"); $smtp->datasend("Ad Info : \n"); $smtp->datasend("Year $year "); $smtp->datasend("Make $make "); $smtp->datasend("Model $model \n"); $smtp->datasend("Description $description \n"); $smtp->datasend("Ad Phone Number $adphone \n"); $smtp->datasend("Client Will Pay by : $payment \n"); $smtp->datasend("Submitted on $datesent \n"); $smtp->datasend("Attachments : \n"); if (@attach) { foreach (@attach) { $value ++; $photoad .= $attach[$value]; $smtp->datasend("$photoad"); } } else { $smtp->datasend("none \n"); } $smtp->data(@attach); $smtp->dataend(); $smtp->quit; } ######################################################################### sub AttachMe { #Check to see if an allowed file type $info = uploadInfo($photo); $kind = $info->{'Content-Type'}; open (UPLOAD,">attach") || Error('File could not be opened'); my ($data, $length, $chunk); while ($chunk = read ($photo, $data, 1024)) { print UPLOAD $data; $length += $chunk; if ($length > 1048576) { $erMsg = "The file is too big. Maximum File size is 1MB"; unlink ("/c:/inetpub/wwwroot/wheelsdeals/cgi-bin/attach") || Error('File does not exist'); Error ($erMsg); exit; } } @attach = ; close (UPLOAD); print "$photo of $kind was uploaded to server."; if ($erMsg) { Error ($erMsg); } } ######################################################################### sub Error { if ($_[0]) { print "$_[0] \n"; print "$! \n"; exit; } else { print "ERROR of Unknown type. Please contact system administrator."; print "$! \n"; exit; } }