Here is the code. Near the beginning of the code, they define:
$SMTPMailServer = 'wwwsvr.theirdomain.org';
When I try this same code on our unix mail server, it runs perfectly. So I must be missing something exclusive to NT.
One more note: My client just installed Perl for this script, so it could be their installation or it could be my code. Unfortunately, I don't have access to their server.
Thanks again.
David
#!/usr/local/bin/perl # Point the previous line to the location of Perl on your server # On NT the first line would be something like #!e:\Perl\bin\Perl.exe
# There are two ways to set the email method
# Method 1 - Use with Unix servers and some NT servers # Set the $mailprog variable to point to the mail system on your server. # If you are on a unix server, it is probably correct. # Sendmail, mail, and qmail are the most common. Your ISP should # be able # to give you the path and name of your server mailing program. # You only need to set the next line if you use Method 1.
$mailprog = '/usr/sbin/sendmail';
# Method 2 - Use this on NT servers that do not have a sendmail program. # You must have the perl module Net::SMTP installed on your server. # Set the part between the single quotes to the SMTP mail host name. # An example would be: $SMTPMailServer = 'mailhost.server.com'; # If you are using Method 1, there should be nothing between the quotes.
$SMTPMailServer = '';
# If Blat is used then set the path to Blat.exe & specify a temporary # file name. If Blat is not being used, leave both variables blank. # Example: $blatpathname = "e:\blat\blat.exe"; # Example: $tempfilename = "e:\inetpub\vs20\cgi-bin\blat\mailtemp$$"; $blatpathname = ''; $tempfilename = '';
# After uploading this file to your server you MUST set the permissions. # Set the permissions for User to Read, Write and Execute (numeric code 700).
#--------------------------------------------- # ------- End of User Setup Variables -------- #---------------------------------------------
# Read the data from the form read(STDIN, $frmdat, $ENV{'CONTENT_LENGTH'});
# Split the data into its parts. @namval = sort(split(/&/,$frmdat)); foreach (@namval) { tr/+/ /; s/=/ = /; s/%(..)/pack("C",hex($1))/ge; ($nam, $val) = split(/ = /,$_,2); $dat{$nam} = $val; }
# --------- Read the variables passed from the form ---------
# Get the email address where the data from the form should be sent $email = $dat{'recipient'};
# Get the subject line for the emails (same as codebook name) $studyname = $dat{'studyname'};
# URL of the next page # if url = the word "default" then then next page is an automatic thankyoupage $nextpage = $dat{'nextpage'};
# Form processing method: email or file $method = $dat{'method'};
# Location of directory when responses are saved to a file $storagepath = $dat{'directory'};
# If the url has a ?xxxxx then the respondent ID already exists # Otherwise, create a new respondent ID $Fullurl = "$ENV{'HTTP_REFERER'}"; $Position = index($Fullurl,"?"); if ($Position > 0) { $respondentID = substr($Fullurl,$Position+1); # also remove bookmark if necessary $Position = index($respondentID,"#"); if ($Position > 0) { $respondentID = substr($respondentID,0,$Position); } } else { $respondentID = int(100 + rand 99999899); }
# --------- Use Mail Program to Send Mail Now ----------
if ($method eq 'email') {
&process_form;
if ($SMTPMailServer eq '') {
open(MAILOUT, "| $mailprog $email") || &showerror("Cannot start mail program:","$storagepath $email"); print MAILOUT "Subject: $studyname\n\n"; # For each form field, print the form field and value. foreach $field (@Field_Order) { print MAILOUT "$field: $Form{$field}\n"; } # Print blank line after each form print MAILOUT "\n"; close(MAILOUT);
} else {
if ($blatpathname eq '') {
use Net::SMTP; $smtp = Net::SMTP->new($SMTPMailServer); $from = $email; # You can change the From email address to anything here (leave the \ before the @) # $from = "surveys\@yourdomain.com"; $subject = $studyname; # You can change the subject line to anything you want here # $subject = "Type any subject line here"; $smtp->mail($from); $smtp->to($email); $smtp->data(); $smtp->datasend("To: ", $email, "\n"); $smtp->datasend("Subject: ", $subject, "\n"); $smtp->datasend("\n"); foreach $field (@Field_Order) { $smtp->datasend("$field: $Form{$field}\n"); } $smtp->dataend(); $smtp->quit;
} else {
# Blat is being used open(outfile,">$tempfilename"); foreach $field (@Field_Order) { print outfile "$field: $Form{$field}\n"; } print outfile "\n"; close(outfile); system("$blatpathname $tempfilename -s $subject -t $email -server $SMTPMailServer -f $email"); }
}
# --------- Save Response to a File on the Server -----------
} elsif ($method eq 'file') {
# Name the output file the same as the codebook.asc srand; $storagefilename = $studyname; $storagefilename =~ s/\W/_/g; $outputfile = "$storagepath"."$storagefilename".".asc";
# open(MAILOUT,">>$outputfile"); # flock MAILOUT,2; # if (-e $storagepath) {
# Begin header with the user's IP address $responseID = "$ENV{'REMOTE_ADDR'}";
# End header with date @days = ('Sunday','Monday','Tuesday','Wednesday', 'Thursday','Friday','Saturday'); @months = ('January','February','March','April','May','June','July', 'August','September','October','November','December'); ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; $time = sprintf("d:d:d",$hour,$min,$sec); $year += 1900; $date = "$days[$wday], $months[$mon] $mday, $year at $time";
&process_form;
# Begin header with the user's IP address # First line of the email header follows print MAILOUT "StatPac_ID: "."$responseID\n";
# Second line of the email header follows print MAILOUT "Respondent_ID: "."$respondentID\n";
# Last line of the email header follows print MAILOUT "Date_Time: "."$date\n";
# For each form field, print the form field and value. foreach $field (@Field_Order) { print MAILOUT "$field: $Form{$field}\n"; } # Print blank line after each form print MAILOUT "\n";
close(MAILOUT);
} else { print "Content-type: text/html\n\n"; print "<HTML>"; print "<HEAD>"; print "<TITLE> $studyname </TITLE>"; print "</HEAD>"; print "<BODY BGCOLOR=\"#FFFFFF\">"; print "<FONT SIZE=\"5\" COLOR=\"#000000\" FACE=\"Arial\">"; print "<FORM>"; print "<CENTER>"; print "<B>The server is busy.</B><BR>"; print "Please press the Back button on your browser and try again."; print "</CENTER>"; print "</FORM>"; print "</FONT>"; print "</BODY>"; print "</HTML>"; close(STDOUT); exit 0; }
# Erase any embedded carriage returns, tabs, line feed, & form feed characters $value =~ s/[\r\t\n\f]/ /g;
# Put special field names in the %Config array & others in the %Form array # Save the order of the form fields in the @Field_Order array if (defined($Config{$name})) { $Config{$name} = $value; } else { if ($Form{$name} && $value) { $Form{$name} = "$Form{$name}, $value"; } elsif ($value) { push(@Field_Order,$name); $Form{$name} = $value; } } } }