200 OK has nothing to do with successful mail sending. There could be hundreds of different reasons for failure. In your PHP code, I did not find a single line where you would even try to send mail. The fragment of code shown suggests that you probably planned to send mail using this function:
http://php.net/manual/en/function.mail.php[
^].
How would you expect some help if we don't know. But even from this fragment one can see you are doing something wrong. You are sending everything in one
datastring
. How can you ever expect that this data gets in the
$_POST
under three different keys? To use this object, you need to pass all data in key-value pairs. For that matter, I have no idea why you decided to use Ajax. A simple form would easily to it without any serious effort. Please study this:
http://php.net/manual/en/tutorial.forms.php[
^].
Of course, you could do the same with jQuery Ajax, I just don't know why. You can find a lot of code samples around.
But this is still not the worst thing. The worst thing is: if you work in this way, representing data with a string, instead of structured HTML data, and if you are not trying to sanitize it, even a dump malicious artist will turn your server host into a zombie sending spam or something like that. Please see my answer with detailed explanations:
unable to send mail , it showing the error in below code .[
^].
See also:
In what way $('#myelement').valid(); works[
^].
What to do? Well, I would through out your code and write it again, this time, understanding what you are doing. The problem is quite trivial. I would start with sending the mail using exact same credentials with some existing mail program. In case of any problems, debug and/or log all data as you go, on both client (it's not really needed if you simply use forms) and server side, and so on…
—SA