Ik heb onderstaande code om te checken of er een geldig emailadres wordt ingevoerd, maar er komt heel vaak de melding dat het geen geldig emailadres is terwijl dit wel zo is. Hoe kan ik het toch goed checken maar wel zo dat hij alle geldige emailadressen gewoon accepteert?
Ik denk dat het iets is met die DNS?
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]function[/COLOR] checkmail[COLOR= #007700]([/COLOR][COLOR= #0000BB]$mail[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #FF8000]// explode het e-mail adres op een @[/COLOR]
[COLOR= #0000BB]$email_host[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"@"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$mail[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// pak alles na de @[/COLOR]
[COLOR= #0000BB]$email_host[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$email_host[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #FF8000]// zet een var met de (eventuele) DNS van de domein[/COLOR]
[COLOR= #0000BB]$email_resolved[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/gethostbyname"]gethostbyname[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$email_host[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// kijk of er een DNS aan zit en of alles voor en na het e-mail adres klopt[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$email_resolved[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]$email_host[/COLOR] [COLOR= #007700]&&[/COLOR] [URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$mail[/COLOR][COLOR= #007700]))[/COLOR]
[COLOR= #0000BB]$valid[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// wanneer het geldig is, is $valid = 1, zo niet, dan geeft hij geen result (NULL)[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$valid[/COLOR][COLOR= #007700];
}[/COLOR]
?> Ik denk dat het iets is met die DNS?




