Hi, I'm having a problem sending an email with sendmail. (CGI)

what I need to do is take the parameters from input form, use those to extract an email address and send an email to that address

I have tested the script using a straight typed email address, and it works, as does an email picked up using $blah= param(blah). However when I try with an address extracted from my DB the email isn't sent

I have used the straight email and also replacement: s/@/\@/; I really can't understand what is happening and wondered if someone would mind taking a look and letting me know what I'm doing wrong.

#!/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 ($Password,$U_Timestamp,$three,$four,$skipthisfield); my @emailer = (); my $data="/home/users/t/my_site.com-99078/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) { push (@emailer, $four); last; } } my $Email_address = join (" ", @emailer); $Email_address =~ s/@/\@/; print "Content-type: text/html\n\n"; print "Thank you:<br>\n <br>Detailss $id_in<br>\n"; print "three is: $three"; print "Email is: $Email_address<br>"; print "Check is: $check"; &sending(); #SEND EMAIL================================= sub sending { my $check; my $sendmailer; my $emailto; my $Email_address; my $emailfrom; my $message_no; my $message; $Email_address =~ s/@/\@/; if ($check == 0) { $sendmailer="/usr/sbin/sendmail"; $emailto="$Email_address"; $emailfrom="enquiry\@my_site.com"; 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); } elsif ($check == 1) { $sendmailer="/usr/sbin/sendmail"; $emailto="$Guest_Email"; $emailfrom="enquiry\@my_site.com"; open (MAIL, "| $sendmailer -t") || die "sendmailer: $!"; print MAIL "To: $emailto\n"; print MAIL "From: $emailfrom\n"; print MAIL "Subject: Response from owner\n"; print MAIL "Content-type: text/html\n\n"; print MAIL "<html><body><p>\n"; print MAIL "<font size=\"2\" color=\"#FFCC00\">\n"; print MAIL "You have a response from the owner of property: $id_in.<br +>\n"; print MAIL "<br>\n"; print MAIL "Message follows:<br>\n"; print MAIL "$message<br><br>\n"; print MAIL "\n"; print MAIL "</font></body></html>\n"; last; close(MAIL); close(MAIL); } elsif ($check == 2) { $sendmailer="/usr/sbin/sendmail"; $emailto="$Email_address"; $emailfrom="enquiry\@my_site.com"; open (MAIL, "| $sendmailer -t") || die "sendmailer: $!"; print MAIL "To: $emailto\n"; print MAIL "From: $emailfrom\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 "<br>\n"; print MAIL "Message follows:<br>\n"; print MAIL "$message<br><br>\n"; print MAIL "\n"; print MAIL "</font></body></html>\n"; last; close(MAIL); close(MAIL); #end of patch } elsif ($check == 3) { $sendmailer="/usr/sbin/sendmail"; $emailto="$Guest_Email"; $emailfrom="enquiry\@my_site.com"; open (MAIL, "| $sendmailer -t") || die "sendmailer: $!"; print MAIL "To: $emailto\n"; print MAIL "From: $emailfrom\n"; print MAIL "Subject: Response from owner\n"; print MAIL "\n"; print MAIL "You have a response: $id_in.<br>\n"; print MAIL "Please click the following link:<br>\n"; print MAIL "<br>\n"; print MAIL "$message<br><br>\n"; print MAIL "\n"; last; close(MAIL); close(MAIL); } }

In reply to 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.