The script below is designed to send email to the registrant and reply success back to the page for certain actions, if sent by mail, anyway, if I added the php mail() method, the callback response no longer works, the email address was successfully delivered to mailbox, but I was not lucky to receive a success warning, as soon as I delete the mail() method, a success warning appears again, I received some tips on Json.response did not form, but I really do not know how this works, can anyone anything be able to do this, I only want to deliver mail and receive a βsuccessfulβ callback?
request.php
if(empty($fname) || strlen($fname) < 3){ $message['error']['fname'] = 'Full name is required'; } if(empty($contact)){ $message['error']['contact'] = 'Contact number is required'; } if(!isset($message['error'])){ $create = "//sql for insertion"; if($create){ //problem is here $to = $email; $subject = "Email Validation"; $message = "http://www.sitename.com/activate.php?token=".$activate_code; $from = " post@mail.com "; $headers = "From:" . $from; if(mail($to,$subject,$message,$headers)){ $message['success'] = "success"; } } } } echo json_encode($message);
Thanks.
Update:
Finally, resolving the found conflict to $message vs $message['success'] , I changed $message to something else.
Thanks for watching my post.
source share