• I have a client that is using Contact Form 7 and their clients are primarily Government and Non-profit organizations… for some reason the contact form is not accepting .gov and .org email addresses. They are receiving gmail.com just fine but anything outside of a .com email is treated as invalid. How can I allow emails from Gov and NP .org’s? I found this bit of code to block free emails, how can i change it to allow .gov, .org’s etc?

    // Add custom validation for CF7 form fields
    function is_company_email($email){ // Check against list of common public email providers & return true if the email provided *doesn't* match one of them
    	if(
    		preg_match('/@gmail.com/i', $email) ||
    		preg_match('/@hotmail.com/i', $email) ||
    		preg_match('/@live.com/i', $email) ||
    		preg_match('/@msn.com/i', $email) ||
    		preg_match('/@aol.com/i', $email) ||
    		preg_match('/@yahoo.com/i', $email) ||
    		preg_match('/@inbox.com/i', $email) ||
    		preg_match('/@gmx.com/i', $email) ||
    		preg_match('/@me.com/i', $email)
    	){
    		return false; // It's a publicly available email address
    	}else{
    		return true; // It's probably a company email address
    	}
    }
    function custom_email_validation_filter($result,$tag){
    	$type = $tag['type'];
    	$name = $tag['name'];
    	if($name == 'company-email'){ // Only apply to fields with the form field name of "company-email"
    		$the_value = $_POST[$name];
    		if(!is_company_email($the_value)){ // Isn't a company email address (it matched the list of free email providers)
    			$result['valid'] = false;
    			$result['reason'][$name] = 'You need to provide an email address that isn\'t hosted by a free provider.<br />Please contact us directly if this isn\'t possible.';
    		}
    	}
    	return $result;
    }
    add_filter('wpcf7_validate_email','custom_email_validation_filter', 10, 2); // Email field
    add_filter('wpcf7_validate_email*', 'custom_email_validation_filter', 10, 2); // Req. Email field
    
    • This topic was modified 8 years, 2 months ago by chrismelfi.
    • This topic was modified 8 years, 2 months ago by chrismelfi.
    • This topic was modified 8 years, 2 months ago by chrismelfi.
    • This topic was modified 8 years, 2 months ago by chrismelfi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Try removing the code you quoted, deactivating all other plugins, and switching theme to the default one (twentysixteen).

    Thread Starter chrismelfi

    (@chrismelfi)

    I really appreciate you getting back to me… especially so quickly. But, I am not using the code above. My client has a paid-for pro version theme. They aren’t using many plugins it is very slimed down… CF&, Yoast SEO, Microthemer and Layerslider, thats it for plugins. Ive done web based marketing for over ten years… this isn’t my first rodeo. I actually gave your plugin the benefit of the doubt and called their hosting provider first because I thought it was an SMPT error/issue on the servers.

    I didn’t say the plugin was broken or that it does not work as stated. I simply asked how I can add the code above to allow additional TLD email extensions… but alas, it’s “pass the buck” just as you have done blaming the theme and/or other plugins.

    How would destroying the site help me in this situation? We have no other form/lead capture plugins on the site so that isn’t the issue. How would turning everything off change the function of your plugin? Is there a line of code I can add to the functions .php that can be edited to allow different TLD email extensions as they are needed in the future, something I can use to return validation as True for .gov and .org emails etc?

    Here is the website on builtwith so you can see what they have going on…. https://builtwith.com/ctrhcm.com Do you see something here that would conflict with your plugin? If so I can address it with them and see if something can be edited on their end. I still am of the opinion it is a server issue… thats why I asked if I can use some code to allow it on our end. Thank you in advance for you patience in this issue.

    chris

    • This reply was modified 8 years, 2 months ago by chrismelfi. Reason: added builtwith url
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘.gov and .org Emails Not Accepted’ is closed to new replies.