Darn it! I had the $Email_address = $four; and then changed it just before posting - thanks for pointing it out.
I tried adding debugging and just inserted a print "Email_address"; further down the script and decided I would get rid of the subroutine element and the (check=) statements just to try to simplify it. Immediately I received an email generated from the script! Progress, but it comes with befuddlement!!. what I have now is:
#!/usr/bin/perl -w
use strict;
use CGI;
my $query = new CGI;
my $thisurl = "http://www.my_site.com/cgi-bin/email.pl";
my $id_in=$query->param('id_in');
my $Guest_Email=$query->param('Guest_Email');
my $check=$query->param('check');
my $Email_address;
my ($Password,$U_Timestamp,$three,$four,$skipthisfield);
my @emailer = ();
my $data="/path/data/edit/data.txt";
open (FILE, "$data");
while (my $line =<FILE>) {
($Password,$U_Timestamp,$three,$four,$skipthisfield) = split "\t",
+$line;
if ($id_in eq $three) {
$Email_address = $four;
last;
}
}
print "Content-type: text/html\n\n";
my $sendmailer;
my $emailto;
my $emailfrom;
my $message_no;
my $message;
$sendmailer="/usr/sbin/sendmail";
$emailto="$Email_address";
$emailfrom="enquiry\@my_site.com";
print "Email is: $Email_address";
open (MAIL, "| $sendmailer -t") || die "sendmailer: $!";
print MAIL "To: $emailto\n";
print MAIL "From: $emailfrom\n";
print MAIL "Subject: Request for information\n";
print MAIL "Content-type: text/html\n\n";
print MAIL "<html><body><p>\n";
print MAIL "<font size=\"2\" color=\"#CC0000\">\n";
print MAIL "<u>REQUEST FOR INFORMATION</u><BR><BR>\n";
print MAIL "I am interested in receiving information on : $id_in<BR>\n
+";
print MAIL "blah\n";
print MAIL "Any other comments:<BR>\n";
print MAIL "$message<br>\n";
print MAIL "</font></body></html>\n";
last;
close(MAIL);
close(MAIL);
Any ideas why it should work like that but not in the previous version? (At least this gives me a basis to start looking but there might be something obvious which I'm not getting). |