I'm a beginner in php
and found a simple mail function. Following is the code:
private function sendEmail() {
$to = $this - > email;
$subject = $this - > subject;
$message = $this - > name. " : ". $this - > message;
$header = "From: ".$this - > email;
$mail = mail($to, $subject, $message, $header);
echo $to, $subject, $message, $header, $mail, "End";
if ($mail) {
$this - > response_status = 1;
$this - > response_html = 'Thank You!';
} else {
echo "Mail not found";
}
}
When I call it from Javascript, it always lands in error block of $.ajax
but no error message it thrown. When I check response of ajax call in network tab, I get proper values of all variables ($to, $subject, $name, $message, $header), but $mail
is always blank.
Also I get Mail not found from else block.
Can anyone point me in the right direction?
I'm running it on localhost on XAMPP (on Ubuntu 15.10).
Following is the snapshot of response: