Jump to content

Email Form Script Problem


jdleon

Recommended Posts

I created an email form script which I am currently testing on my site. It is working fine but I am have a small problem. On my receiver email variable:

$to = '[email protected]';

I am not getting the emails once the form is submitted - not even in the spam folder. If I replace it with a yahoo, hotmail, or excite email account - I get the emails with no problems. It's just when I put the gmail account, I don't get the emails - even though the script does says it sent the email. I have check the logs for errors but there are none. Any suggestions why this might be happening, and only with a gmail account?

Link to comment
https://forums.phpfreaks.com/topic/188620-email-form-script-problem/
Share on other sites

Here's my script 

 

 

if ($_POST['submit'])
  {
  // Get data
  $firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $email = $_POST['email'];
  $phone = $_POST['phone'];
  $comments = $_POST['comments'];
  
  if ($firstname && $lastname && $email && $comments)
  {
	 	  
	   $visitor = $firstname . ' ' . $lastname;
	   $to = "[email protected]";
                   $subject = "Valley Safety Services: Information Request";
	   $headers = "From: $visitor <$email>";
	   
	   $message = "From: $visitor\r\n\r\n";
           $message .= "Email: $email\r\n\r\n";
           $message .= "Phone: $phone\r\n\r\n";
	   $message .= "$comments";
	   
	   $mailsent= mail($to, $subject, $message, $headers);
	   
	   if ($mailsent)
	   {
                        echo'Email sent succefully!';
	   }
      
  }

 

 

 

The From header needs to be a valid email address on the server actually sending the email. Otherwise some smtp services (gmail too apparently) will think your attempting to forge someone else's email.

 

Ok, I'll change my From header and give it a try.  Thanks thorpe!

I changed the From headers and added a valid email address, but I still didn't get the email.  So I think I know what might be the problem.  I created another gmail account, added to my script, and I got the emails.  I put back my old gmail account and I still didn't get anything.  The only difference between my old gmail account and the new one that I created that the new account doesn't have a period in between the name.  What I mean is, my old gmail account is [email protected].  My new account is just [email protected].  Could the period be the problem?

Archived

This topic is now archived and is closed to further replies.

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