1

i will send mail using php mail function but it can display some error..

Warning: mail(): Failed to connect to mail server at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in

mail.php

    <?PHP
    $sender = 'sender123@gmail.com';
    $recipient = 'resever123@gmail.com';

    $subject = "php mail test";
    $message = "php test message";
    $headers = 'From:' . $sender;

    if (mail($recipient, $subject, $message, $headers))
    {
        echo "Message accepted";
    }
    else
    {
        echo "Error: Message not accepted";
    }
    ?>
Pradeep
  • 9,667
  • 13
  • 27
  • 34
Jadav Ramesh
  • 11
  • 1
  • 7

1 Answers1

1

If you are testing on your localhost you most likely dont have an SMTP setup. You have to setup an smtp connection for php to send the message.

I would suggest using something like phpmailer which makes it easier when working on local testing servers.

James
  • 702
  • 2
  • 15
  • 39