【问题标题】:failed to connect to mailserver at localhost无法连接到本地主机的邮件服务器
【发布时间】:2018-06-12 14:05:32
【问题描述】:

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

 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>

我应该怎么做才能消除这个错误?

【问题讨论】:

标签: php email


【解决方案1】:

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

  1. 邮筒。 https://www.mailgun.com 。 - 他们每月提供 1 万封电子邮件,
  2. AWS SES - 他们有每月免费电子邮件计划,

您必须注册一个域,即使 localhost 也适用于其中任何一个,并且必须获取 SMTP 设置

【讨论】:

    猜你喜欢
    • 2011-09-08
    • 2019-09-21
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-14
    相关资源
    最近更新 更多