• GoDaddy Community
  • Website Design & Development
  • Website Design & Development

    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 

    Can send email using PHP contact form but recipients can't can't receive it

    I'm trying to test out a simple email form on my website to see if I can get it to work. The email sends out just fine, but when I use my yahoo email address as the recipient for incoming emails to test it, no email ever arrives. I'm hard pressed to figure out why


    This is the PHP code I'm using.


      // Message Vars
    	$msg = '';
    	$msgClass = '';
    	// Check For Submit
    	if(filter_has_var(INPUT_POST, 'submit')){
        // Get Form Data
    		$name = htmlspecialchars($_POST['name']);
    		$email = htmlspecialchars($_POST['email']);
        $message = htmlspecialchars($_POST['message']);
    		// Check Required Fields
    		if(!empty($email) && !empty($name) && !empty($message)){
          // Passed
          // Check Email
    			if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
            // Failed
    				$msg = 'Please use a valid email';
    				$msgClass = 'alert-danger';
          } else{
            // Passed
            // Recipient Email
            $toEmail = 'dylancougar@yahoo.com';
    				$subject = 'Contact Request From '.$name;
            $body = '<h2>Contact Request</h2>
            // Email Headers
    				$headers = "MIME-Version: 1.0" ."\r\n";
            $headers .="Content-Type:text/html;charset=UTF-8" . "\r\n";
            // Additional Headers
            $headers .= "From: " .$name. "<".$email.">". "\r\n";
    				if(mail($toEmail, $subject, $body, $headers)){
              // Email Sent
    					$msg = 'Your email has been sent';
    					$msgClass = 'alert-success';
            } else {
              // Failed
    					$msg = 'Your email was not sent';
    					$msgClass = 'alert-danger';
        } else {
          // Failed
          $msg = 'Please fill in all fields';
          $msgClass = 'alert-danger';



    2 REPLIES 2
    Community Team

    Could be a few things. I did a quick search to see what others have done for troubleshooting PHP mail. This useful list came up in a Stack Overflow thread:


    • Does the sender address ("From") belong to a domain on your server? If not, make it so.
    • Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a remote possibility with shared hosting.
    • Are mails filtered by a spam filter? Also, try sending mail to an address without a spam filter.
    • Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)
    • If you have access to log files, check those, of course, as suggested above.
    • Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.


    Let us know how you make out. 🙂

    Senior Community Manager, GoDaddy Pro
    Need help with your account? Find 24/7 support at x.co/247support
    Browse our articles for website designers & developers on the GoDaddy Blog.
    Do you build websites for others? Join the GoDaddy Pro partner program.
    Follow @GoDaddyPro on Twitter for helpful tips, useful links and exclusive updates.

    So I'm guessing that the recipient for incoming emails has to be on a Go daddy server. I used my Godaddy email address and this time it actually worked.