0

I been trying to create a form that allows user to send information to my email, but only about 50% of the time that the data actually comes through. Is it something within the PHP or regarding to the email service I'm sending the data to?

<?php


    $name = $_POST['q1'];
    $visitor_email = $_POST['q2'];
    $interest = $_POST['q3'];
    $current = $_POST['q3.5'];
    $designer = $_POST['q4'];
    $link = $_POST['q5'];

//Validate first
if(empty($name)||empty($visitor_email)) 
{
    echo "Name and email are missing!";
    exit;
}

if(IsInjected($visitor_email))
{
    echo "Bad email value!";
    exit;
}

        $email_from =   'username@gmail.com';
    $email_subject = "Application Submission";
    $email_body =   "You have received a new message from the user $name.\n".
                        "Email: $visitor_email.\n".
                        "Interest: $interest.\n".
                        "Design: $designer.\n".
                        "Link: $link.\n".

        $to = 'username@gmail.com';
    $headers = "From: $email_from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";
    mail($to,$email_subject,$email_body,$headers);
        header('Location: thank-you.html');

// Function to validate against any email injection attempts
function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}

?>
Junny
  • 1
  • 1
  • Do the mail logs on your server show that the mail is being sent out? If so, it's happening on the service you're sending to. – Barmar May 02 '15 at 01:03
  • if you are sending this out via the web server directly (i.e. not through gmails servers or other reputable mail server) it's quite possible the emails are just being delayed. expect them in your inbox within the next week :) bon voyage – Jonathan May 02 '15 at 01:04
  • I receive some instantly, then if I send it again, it will not come through. I been testing it out myself, just sending the data over and over again, works about 50% of the time, can't figure out why! – Junny May 02 '15 at 01:06
  • Are they going into the spam folders? – Mike May 02 '15 at 01:10
  • No, I've checked. Also tried different email services but same thing – Junny May 02 '15 at 01:52

0 Answers0