Jump to content

[SOLVED] How to exclude a specific email address


bubblybabs
 Share

Recommended Posts

I wish to exclude a specific email address when one sends an ecard from my site.  How does one exlude this email address but allow all others to continue on their merry way?

 

Code currently used:

 

function validEmail($address)
{
if (eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address))
	return true;
else
	return false;
}

 

Thank-you,

Babs

Link to comment
Share on other sites

taith,

 

I so appreciate your quick response...  Please give me a clue as to how to add this snippet of coding into what I already have...  Should it be as such?

 

function validEmail($address)
{

if (eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address))
	return true;
else
	return false;
}

if(validEmail($_POST[email])){
if(strpos($_POST[email],'bad@email.host')!==false){
FLEEFROMMYWRATH($baduser);
}else{
}
}

 

Babs

Link to comment
Share on other sites

sorry... not really sure what you mean by that... this should work as is... but it really depends on how your script works...

 

function validEmail($address){
if(eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) return true;
else return false;
}

if(validEmail($_POST[email])){
if(strpos($_POST[email],'bad@email.host')!==false){
  die('I dont like that user... go away!');
}else{
  #continue your script
}
}

Link to comment
Share on other sites

My dear, this is looking good...  I had to modify this a bit to work in the script I am using but it worked...  One exception, how does one make it so that it's not case sensitive?  Right now, if I were to put this email address into the code:

happy@happy.com

but the person typed in :

Happy@happy.com

it will go through.  An error is produced if the two are typed in exactly the same however...

 

Also, is there a way to block all emails from a specific domain?  For example, all emails to @happy.com?

 

Thanks,

Babs

Link to comment
Share on other sites

I think I found the answer...  I changed strpos to stristr...  Is this correctly used?

 

function validEmail($address)
{
if(eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) 
	return true;
else 
	return false;
}

if(validEmail($_POST[to_email])){
if(stristr($_POST[to_email],'happy@happy.com')!==false){
die('I am sorry but you are not allowed to send to that email address.  Please go <a href="compose.php">back</a> and fix the error.');
}else{
return false;
}
}

 

I can put in happy@happy.com and change any letter to a capital and it seems to give me the error message so I think this is correct...

 

Thanks,

Babs

Link to comment
Share on other sites

OK, took me a bit to figure this out:

 

function validEmail($address)
{
if(eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) 
	return true;
else 
	return false;
}

if(validEmail($_POST[to_email]))
{
if(strpos(strtolower($_POST[to_email]),'happy@happy.com')!==false)
{
die('So sorry but you are not allowed to send to that email address.  
Please go <a href="compose.php">back</a> and resend to another email address.  Thank-you!.');
}else{
return false;
}
}

 

Is that correctly coded?

 

Thanks bunches...

 

Babs

Link to comment
Share on other sites

*giggles*

Yes, it works!  I just worry I've gotten it to work but some hidden other "side-code" is occurring w/o my knowledge!

:-)

Many thanks taith, I appreciate your assistance and helping me learn yet another fascinating snippet of php...  Consider this solved!

Babs

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.