So, to clear up the seemingly random characters up there, that's a / to open it, and escaped @ sign, a *, an escaped ., then another / to close it. Essentially I'm looking for an @ sign then a dot. On the console, this line works great, catches mistakes and everything. But when I run it through a web page as a CGI script it doesn't catch it unless I don't put anything in the field. Any ideas? Here's all of the code, just to see if anybody catches a minor mistake in my code:if ($MailTo !~ /\@*\./) { #set a kill flag #print a message }
use Net::SMTP; use CGI ':standard'; #Get parameters from http string# my $ServerName = param('server'); my $MailFrom = param('from'); my $MailTo = param('to'); my $Subject = param('subject'); my $Content = param('content'); print "Content-type: text/html\n\n"; print "<html>\n <head>\n <title>Mail Results</title>\n </head>\n <body>\n"; my $kill = 0; if (!($MailFrom =~/\@*\./)) { $kill = 1; print "Invalid return address in From box. "; } if (!($MailTo !~/\@*\./)) { $kill = 1; print "Invalid destination address. Please notify the webmaster o +f this problem by sending an email to wvhs-web\@charter.net. "; } if ($kill == 1) { die("One or more errors have occurred which prevent the script fro +m continuing further. "); } else { $smtp = Net::SMTP->new($ServerName, Debug => 0); die "Couldn't connet to server: $!" unless $smtp; $smtp->mail($MailFrom); $smtp->to($MailTo); $smtp->data(); $smtp->datasend("To: $MailTo\n"); $smtp->datasend("From: $MailFrom\n"); $smtp->datasend("Subject: $Subject\n"); $smtp->datasend("\n"); $smtp->datasend("$Content\n\n"); $smtp->dataend(); $smtp->quit(); print "Mail Sent Successfully\n \n"; } print "</body>\n </html>";
edited by ybiC: Balanced <code> and <readmore> tags, retitle from "Regex problem"
In reply to email address validation regexp by wallyweezle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |