Forum Moderators: phranque
if (ereg("@aol\.com",$email)) {
header ('Location: http://www.example.com/toughmessage.htm');
} works well at blocking lower case email addresses. But what about someone who uses upper case?
Well
$email = strtolower($email);
if (ereg("@aol\.com",$email)) {
header ('http://www.example.com/toughmessage.htm');
} knocks that on the head. BUT. if I do a blanket change of all case to lower for all emails, would that ever cause problems for an email address that correctly had upper case letters in it - or in practice do all email handlers treat upper and lower case the same in email addresses?
[edited by: encyclo at 12:02 am (utc) on Oct. 18, 2008]
[edit reason] fixed formatting [/edit]
See RFC2821 [ietf.org]:
The local-part of a mailbox MUST BE treated as case sensitive. Therefore, SMTP implementations MUST take care to preserve the case of mailbox local-parts. Mailbox domains are not case sensitive. In particular, for some hosts the user "smith" is different from the user "Smith". However, exploiting the case sensitivity of mailbox local-parts impedes interoperability and is discouraged.
I think you will find that you will have no problem in switching the entire email address to lower-case, but if you want to be really careful, you could just change the domain name to lower-case.
$email = $_POST['email'];
$email = strtolower($email);
if (ereg("@aol\.com",$email)) {
header ('http://www.example.com/toughmessage.htm');
exit;
}
else {
$email = $_POST['email'];
etc}
So more or less what you suggested.
Quckn'n'dirty - but it works.
The only code you need is:
if (eregi("@aol\.com",$_POST['email'])) {
header ('http://www.example.com/toughmessage.htm');
exit;
}
Anything else should be handled by the rest of your script.