0

I want to send email to entered email address. But I keep getting this error.

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

This is my code

    <?php
    $email=$_POST["email"];

      $message="Your application has been submitted tothe Incharge and Admin of the classes. Thanks for applying at our insitute.";

      mail($email,"Confirm Application", $message, "From: anemade45@gmail.com");
?>
      <form method="post">
        <input type="email" name="email" placeholder="enter your email address">
      </form>

What should I do to remove that error?

Ashwini Nemade
  • 153
  • 1
  • 13
  • 1
    I hope [this](https://stackoverflow.com/questions/19132171/send-email-from-localhost-running-xammp-in-php-using-gmail-mail-server) link will help you – Vijay Makwana Jun 12 '18 at 06:09
  • Do you have a mail-server installed on localhost? – brombeer Jun 12 '18 at 06:22
  • Possible duplicate of [Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp\_port" setting in php.ini or use ini\_set()](https://stackoverflow.com/questions/4591329/failed-to-connect-to-mailserver-at-localhost-port-25-verify-your-smtp-and) – Penguine Jun 12 '18 at 06:23

1 Answers1

0

You cannot send emails from your localhost unless you have set-up some mail agent, I believe, you can get SMTP settings from email providers such as :

  1. Mailgun . https://www.mailgun.com . - they provide 10k emails per month,
  2. AWS SES - they have monthly free email plan,

You have to register a domain, even localhost will work to any of these and have to get the SMTP settings

Gaurav Garg
  • 137
  • 1
  • 9