php Mail script does not work

Posted March 6, 2014 3.5k views
Sir, The php mail script doesn't work while i am host server. That script i have already work in linux server that time it's work but here doesn't work. I have mentioned below what i have done in mail script in php. $to = ''; $subject = 'Contact Form Submitted.'; $body = "Name: "working"; $email=''; $mailchk = mail($to, $subject, $body, $email); if($mailchk) { echo " alert('Activated Successfully. Kindly Check your Mail');"; } else{ echo " alert('error');"; } can you help me..

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers
function sendMail($to, $subject, $message,$from)
$headers = 'From:'. $from . "\r\n" .
'Reply-To:'. $from . "\r\n" .
'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
return TRUE;
return FALSE;

Here is a simple wrapper
Do you have an MTA installed? What's the output of
sudo netstat -plutn | grep 25
? If it's empty, run the following command:
sudo apt-get install sendmail