Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:09:23+00:00 2026-06-11T16:09:23+00:00

I have a PHP email script on my website that potential clients use to

  • 0

I have a PHP email script on my website that potential clients use to contact me. Got it from Stack and tweaked it a little (has a honeypot).

PHP CODE

<?php 

$robotest = $_POST['robotest']; //just testin' for robots

$recipient = "info@agoodman.com.au"; //recipient 
$email = ($_POST['email']); //senders e-mail adress 

if((filter_var($email, FILTER_VALIDATE_EMAIL)) && ($robotest == "")) { 

$Name = ($_POST['name']); //senders name 
$mail_body = ($_POST['comments']); //mail body 
$subject = "Image Consulting Inquiry"; //subject 

$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields 

mail($recipient, $subject, $mail_body, $header); //mail command :) 

} else {
    print "You've entered an invalid email address!";
}
?>

FORM HTML CODE:

<form name="contactform" id="contactform" method="post" action="/contact/" _lpchecked="1">
    <ul class="form-block">

      <!-- HONEYPOT -->
      <li class="on-no-robots" style="height:0px; text-indent:-9999px; font-size:0px; overflow:hidden;">
        <label>Humans Don't Submit This!! If you can see this, you don't have CSS, and you scare me. This is just here to filter out automated comments!</label>
        <input name="robotest" id="robotest" type="text" />
      </li>
      <!-- HONEYPOT -->

      <li class="third">
        <label for="name">Name</label>
        <input type="text" name="name" id="name" value="" class="required" />
      </li>
      <li class="third">
        <label for="email">Email Address</label>
        <input type="email" name="email" id="email" value="" class="required email" />
      </li>
      <li class="third">
        <label for="phone">Phone Number</label>
        <input type="text" name="phone" id="phone" value="" />
      </li>
    </ul>
    <h3>How can we help you?</h3>
    <ul class="form-block">
      <li class="full">
        <textarea name="comments" id="comments" class="required"></textarea>
      </li>
      <li>
        <input id="submitButton" type="submit" value="Talk to us" onclick="_gaq.push(['_trackEvent', 'Conversions', 'Contact', 'Contact Form']);" />
      </li>
    </ul>
</form>

I also have been using Google Analytics’ event tracking on the “submit” button of the form, as follows:

<input id="submitButton" type="submit" value="Talk to us" onclick="_gaq.push(['_trackEvent', 'Conversions', 'Contact', 'Contact Form']);" />

I can test an email and it works fine. However, looking at my analytics, there are a few days where people have clicked the “send” button (triggering the analytics event) but I’ve not received an email. This may be because they haven’t filled out the form correctly, but I’m not sure. There is nothing in my Gmail spam filter.

Is there any way to (a) check with my host to see if there’s any ‘trapped’ email that hasn’t been sent correctly, and (b) tweak the code so that these false positives (if they are false positives) don’t occur?

Obviously the most simple cause would be people just clicking the “submit” button for fun without having entered anything, thus triggering the analytics event. Each of these conversions is worth around $1500 so I’d like to be as certain as possible that they’re not genuine conversions that aren’t getting emailed to me!

Cheers guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:09:24+00:00Added an answer on June 11, 2026 at 4:09 pm

    Modify your script like this. Test it out and see what prints.

    $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields 
    
    $ret = mail($recipient, $subject, $mail_body, $header); //mail command :) 
    
    var_dump($ret);
    

    If you get 0 / false etc, mail() is not enabled on your server. If you see true / 1 etc, most likely your mail is going to spam. If you do not get anything printed on the page (or rather “You’ve entered an invalid email address!” printed… Overlooked that sorry), that means it is just not entering this loop

    if((filter_var($email, FILTER_VALIDATE_EMAIL)) && ($robotest == "")) { 
    

    Tell me what you see?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php pipe script that receives an email, takes an attached *.csv
I have a simple php script on my domain that sends me an email:
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
I need your help. I have a php script to send email to people
I'm clueless when it comes to PHP and have a script that emails the
I have a PHP application that sends email using the pear Mail function. Unfortunately
I have a rough php script that sees if a user has filled in
I have a simple contact form on a website that has 2 text fields,
I have a form on my website that is submitted to my email address;
I'm preparing a website that will send email notifications to registered users. From my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.