无法连接到localhost上的邮件服务器

时间:2018-06-12 05:56:46

标签: php email

我想发送电子邮件到输入的电子邮件地址。但我一直收到这个错误。

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

这是我的代码

    <?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>

我该怎么做才能删除该错误?

1 个答案:

答案 0 :(得分:0)

除非您设置了一些邮件代理,否则您无法从本地主机发送电子邮件,我相信您可以从电子邮件提供商处获取SMTP设置,例如:

  1. Mailgun。 https://www.mailgun.com。 - 他们每月提供10k封电子邮件,
  2. AWS SES - 他们有月度免费电子邮件计划,
  3. 您必须注册域名,即使localhost也可以使用这些域名并且必须获取SMTP设置

相关问题