0

I am working on my localhost with php and first of I used this code to send a mail;

<?php
echo "<h1>Sending Email</h1>";

$emailTo = "saroj@gmail.com";
$subject = "I hope this works";
$body = "Test message";
$headers = "From: sarojkumar.sahoo1998@gmail.com";
//$text = str_replace("\n.", "\n..", $text);
 if (mail($emailTo, $subject, $body, $headers)) {
    echo "Email is sent successfully.";
 }else {
    echo "email not sent!";
 }

?>

And my error is shown in my localhost is like: see error page image

What to do?

Saroj_98
  • 21
  • 4
  • Do you have a local mail server? Looks like that's missing. – tadman May 05 '18 at 15:41
  • You have to install some smtp server in your localhost – Emeeus May 05 '18 at 15:44
  • I have also changed my SMTP server with my domain name, but that doesn't work! – Saroj_98 May 05 '18 at 15:46
  • I dnt think you’re understanding what they mean. You need something like do dovecot/postfix handling stmp requests if you want to use local host as your stmp server – Mason Stedman May 05 '18 at 15:58
  • I completely understand and i worked according to the HOW-TOs Guide of XAMPP . I changed the domain name i.e. Email address and password as par their guide and it doesn't work. Do I need to install SMTP server from other sources ?? – Saroj_98 May 05 '18 at 21:09

0 Answers0