Jump to content

Email Script Sending.


dadvan

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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