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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |