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
https://forums.phpfreaks.com/topic/285917-email-script-sending/
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.

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.