【问题标题】:Failed to connect to mailserver at "localhost" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in wamp server无法在“localhost”端口 587 连接到邮件服务器,验证 php.ini 中的“SMTP”和“smtp_port”设置或在 wamp 服务器中使用 ini_set()
【发布时间】:2017-02-04 13:28:57
【问题描述】:

我在 php 中使用简单的发送电子邮件并收到此错误

警告:mail() [function.mail]:无法连接到邮件服务器 “localhost”端口 587,验证您的“SMTP”和“smtp_port”设置 php.ini 或使用 ini_set() in

<?php
//if "email" variable is filled out, send email
  if (isset($_REQUEST['email']))  {

  //Email information
  $admin_email = "Silicon.abhishekp@gmail.com";
  $email = $_REQUEST['email'];
  $subject = $_REQUEST['subject'];
  $comment = $_REQUEST['comment'];

  //send email
  mail($admin_email, "$subject", $comment, "From:" . $email);

  //Email response
  echo "Thank you for contacting us!";
  }

  //if "email" variable is not filled out, display the form
  else  {
?>

 <form method="post">
  Email: <input name="email" type="text" /><br />
  Subject: <input name="subject" type="text" /><br />
  Message:<br />
  <textarea name="comment" rows="15" cols="40"></textarea><br />
  <input type="submit" value="Submit" />
  </form>

<?php
  }
?>

【问题讨论】:

    标签: php email html-email


    【解决方案1】:

    发送电子邮件需要 SMTP 服务器。您需要在 php.ini 文件中提及 SMTP 主机和 SMTP 端口。如果您的配置正确,那么邮件功能将起作用。有多种 SMTP 服务器可用。您可以搜索它们。

    【讨论】:

    • 我正在使用 wamp 服务器,所以如何在 php.ini 中进行更改
    • @Abhishek 你已经安装了hMailServer?
    • @Abhishek 试试 hMailServer。 Sendmail 很旧,最后一次更新是在 5 年前。按照您为 hMailServer 提到的链接中的步骤操作。
    猜你喜欢
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 2012-08-02
    • 2021-12-24
    相关资源
    最近更新 更多