Jump to content

preg_match - blocking e-mail domains


Kovich

Recommended Posts

Hello everyone.

 

My name is Kovich and today I have a problem that I would like some assistance with. I am using PHP Auto Responder to collect subscriptions to my mailing list located on my blog. I'm getting a ton of great registrations - but mixed in with them are some spam domains - you know, things made with TrashMail, QuickMail, Spam.LA, etc. They're signing up just to get the free gift, and I'd like this to stop. Therefore, I am interested in banning some of these domain names from registering. The system already checks that the e-mail address is in valid format, and if it isn't, it tells the user that the e-mail address is invalid - I would simply like to display this error to anyone using any one of the domains on my list.

 

Therefore, I would appreciate someone walking me through how to add a domain name exclusion to the software. I believe I located the part of the code in which this would need to be implemented. I'm not very good with PHP - I just started following an online tutorial recently, so let's hope for the best. ;) Unfortunately, I'd like to have this problem fixed before I master enough knowledge of the language. =P

 

	function initialize($initialization_data = array()) {

	if (!empty($initialization_data)) {
		if (!empty($initialization_data['id']))						
			$this->id = intval($initialization_data['id']);
		if (!empty($initialization_data['name']))
			$this->name = $initialization_data['name'];
		if (!empty($initialization_data['email']) && preg_match('@^[-!#$%&\'*+/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&\'*+/0-9=?A-Z^_a-z{|}~])*\@[a-zA-Z](-?[a-zA-Z0-9])*(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$@',$initialization_data['email']))
			$this->email = $initialization_data['email'];
		if (!empty($initialization_data['join_date']))
			$this->join_date = $initialization_data['join_date'];
		if (isset($initialization_data['subscribed']))	
			$this->subscribed = ($initialization_data['subscribed']?true:false);
		if (isset($initialization_data['verified']))	
			$this->verified = ($initialization_data['verified']?true:false);			
	}

}

function isReadyForSave() {
	if (!empty($this->name) &&
		!empty($this->email)) 
		return true;
	return false;
}
}

 

It seems logical to me that it goes somewhere in there.

 

So can someone help show me how to block a domain name?

For example: @spam.la

 

Thanks a ton in advance! :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.