0

This code is giving the error that its not connected to mail server.Can any one solve it thanks for your help in advance.

<?php

ini_set('SMTP','myserver');
ini_set('smtp_port',25);

if(isset($_POST["submit"])){
 $name=$_POST["name"]."<br>";
 $email=$_POST["email"]."<br>";
 $subject=$_POST["subj"]."<br>";
 $comment=$_POST["comments"];
 $to="younas_510@yahoo.com";
$headers="From: $name<$email>";
 $messege="Name:$name \n\nEmail:$email \n\n Subject:$subject\n\nMessege:$comment";

 if(mail($to,$subject,$messege,$headers)){

    echo"Email sent";
 }else{
        echo "Please try again";
 }
}
?>
  • Are you running it locally? if yes check these:- [first](http://stackoverflow.com/questions/4591329/failed-to-connect-to-mailserver-at-localhost-port-25-verify-your-smtp-and), [Second](http://stackoverflow.com/questions/4532486/failed-to-connect-to-mailserver-at-localhost-port-25),[Third](http://stackoverflow.com/questions/20981027/failed-to-connect-to-mailserver-at-localhost-port-25-verify-your-smtp),[Fourth](http://stackoverflow.com/questions/21836282/php-function-mail-isnt-working) – Alive to die - Anant Feb 27 '17 at 05:21
  • yes i am running in xampp – Muhammad Younas Feb 27 '17 at 05:30
  • Why are you reading only half of the comment ? you answered "yes" to his question but did you both going over the links he provided ? – Nir Alfasi Feb 27 '17 at 06:32

0 Answers0