PHP email Validation of IBM email only, (World wide)
I am pretty new to PHP, How do I validate an email address to have an IBM domain only? Valid address are:
XXXXX@us.ibm.com
XXXXX@in.ibm.com
XXXXX@ro.ibm.com
XXXXX@ibm.com
The PHP should be able to accept any of the above.
P开发者_Go百科lease help
Thanks
Split on @ then verify with a regex.
list($username,$domain) = explode('@',$email);
if (preg_match('/ibm\.com$/',$domain))
{
echo "yup it's ibm.";
}
First thing to check, is if the email address you got from the email headers is valid i.e.:
John Adams <john@us.ibm.com>
"John Adams" <john@us.ibm.com>
john@us.ibm.com
Then you can verify if it came from an IBM domain by:
if(preg_match('/@([a-z]{2}\.)?ibm.com/i', $emailaddress)) {
# email is from an ibm domain
}
Finally and this is a hard part, make sure that the email was sent from a server owned by IBM, because even me can send you an email with "arvin@ibm.com" as the email address indicated in the From field.
You can list all the IP addresses of IBM's email servers then check if the email originated from them using the email's header fields. Or if your server does SPF checking you can check if the Received-SPF field of the email is "pass".
精彩评论