dadvan Posted February 3, 2014 Share Posted February 3, 2014 Hello, I have this scipt as part of a wordpress theme and it says that the delivery is successful but I am not getting the email. I am not sure what to do to get the email function to work. if(isset($_POST['email'])) {if (!check_email($_POST['email'])){echo 'Please enter a valid email address';}else send_email();}exit;function check_email($emailAddress) {if (filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {return TRUE;} else {return FALSE;}}function send_email() {$message = "\nName: " . $_POST['name'] ."\nEmail: " . $_POST['email'] ;$message .= "\nMessage: " . $_POST['message'] ."\n\nBrowser Info: " . $_SERVER["HTTP_USER_AGENT"] ."\nIP: " . $_SERVER["REMOTE_ADDR"] ."\n\nDate: " . date("Y-m-d h:i:s");$siteEmail = $_POST['receiver'];$emailTitle = $_POST['subject'];$thankYouMessage = "Thank you for contacting us, we'll get back to you shortly.";if(!mail($siteEmail, $emailTitle, $message, 'From: ' . $_POST['name'] . ' <' . $_POST['email'] . '>')){ echo 'error';}else { echo 'success'; }}?> Link to comment https://forums.phpfreaks.com/topic/285917-email-script-sending/ Share on other sites More sharing options...
.josh Posted February 3, 2014 Share Posted February 3, 2014 assuming your form names match the $_POST elements in your script, there's nothing "wrong" with your script (tested it on my own server). However, unless your "From: ... " name/email matches the email server, most email services (e.g. gmail) will likely put it in your spam/junk box or outright deny the email altogether (spam prevention measures).It's also possible your email server is mis-configured. Link to comment https://forums.phpfreaks.com/topic/285917-email-script-sending/#findComment-1467621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.