jdleon Posted January 15, 2010 Share Posted January 15, 2010 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 More sharing options...
trq Posted January 15, 2010 Share Posted January 15, 2010 You probably have poorly formed email headers, post your code. Link to comment https://forums.phpfreaks.com/topic/188620-email-form-script-problem/#findComment-995796 Share on other sites More sharing options...
jdleon Posted January 15, 2010 Author Share Posted January 15, 2010 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!'; } } Link to comment https://forums.phpfreaks.com/topic/188620-email-form-script-problem/#findComment-995807 Share on other sites More sharing options...
trq Posted January 15, 2010 Share Posted January 15, 2010 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. Link to comment https://forums.phpfreaks.com/topic/188620-email-form-script-problem/#findComment-995808 Share on other sites More sharing options...
jdleon Posted January 15, 2010 Author Share Posted January 15, 2010 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! Link to comment https://forums.phpfreaks.com/topic/188620-email-form-script-problem/#findComment-995826 Share on other sites More sharing options...
jdleon Posted January 15, 2010 Author Share Posted January 15, 2010 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? Link to comment https://forums.phpfreaks.com/topic/188620-email-form-script-problem/#findComment-995845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.