email - Why is this PHP script not sending the e-mail? -


note: e-mail address removed privacy purposes.

whenever form executes script, returns success json array @ end, however, e-mail never received @ e-mail address specified.

<?php  if(empty($_post['fullname']) || empty($_post['phonenumber']) || empty($_post['emailaddress']))     {     $response = array('status' => 0, 'txt' => 'please verify required fields complete.');     echo json_encode($response);     die();     }  if(!(preg_match("/^[\.a-z0-9_\-\+]+[@][a-z0-9_\-]+([.][a-z0-9_\-]+)+[a-z]{1,4}$/", $_post['emailaddress'])))     {     $response = array('status' => 0, 'txt' => 'please provide valid e-mail address.');     echo json_encode($response);     die();     }  $name = mysql_real_escape_string($_post['fullname']); $phonenumber = mysql_real_escape_string($_post['phonenumber']); $email = mysql_real_escape_string($_post['emailaddress']); $comments = mysql_real_escape_string($_post['comments']);  $emailbody = 'name: ' . $name . '  phone number: ' . $phonenumber . '  e-mail address: ' . $email . '   comments: ' . $comments . ' ';  mail("example@example.com","new consultation request",$emailbody,"from: noreply@example.com");   $response = array('status' => 1, 'txt' => 'consultation-request-successful'); echo json_encode($response);  ?> 

you've never bothered connecting database, mysql_real_escape_string() going turning boolean false failure - requires active connection db work.

that means $name, $phonenumber, $email, $comments going boolean false, , translated empty string when build mail text.

as well, using mysql escaping simple email beyond utterly pointless. email not vulnerable sql injection attacks.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -