Thread Weitergehende Email-Prüfung
(8 answers)
Opened by Yogi62 at 2010-10-15 10:22
Eine 1-1 Übersetzung:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/perl # modernes perl erzwingen: use strict; use warnings; # Module laden: use CGI; # Das Script ist ein CGI use Net::DNS; # DNS Abfragen # init der Module my $cgi=CGI->new(); my $dns=Net::DNS::Resolver->new(); # CGI Header ausgeben print $cgi->header(); # ab hier ist es die 1-1 Umsetzung: if($cgi->param('mail')) { my $addr=$cgi->param('mail'); my ($user,$host)=split('@',$addr); if($dns->query($host, 'MX') or $dns->query($host, 'A')) { print "1\n"; } else { print "0\n"; } } else { print "0\n"; } Aber wie pq schon sagte nimm besser Email::Valid: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #!/usr/bin/perl # modernes perl erzwingen: use strict; use warnings; # Module laden: use CGI; # Das Script ist ein CGI use Email::Valid; # init der Module my $cgi=CGI->new(); # CGI Header ausgeben print $cgi->header(); my $addr=$cgi->param('mail') || ''; if(Email::Valid->address($addr)) { print "1\n"; } else { print "0\n"; } Last edited: 2010-10-15 12:36:00 +0200 (CEST) |