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).

In reply to Re: Re: Re: emailing with an address taken from a database by jonnyfolk
in thread emailing with an address taken from a database by jonnyfolk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.