无法连接到"localhost"上的邮件服务器端口587,请验证您的"SMTP"和"smtp_port"在php.ini中设置或在wamp服务器中使用ini_set() [英] 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

查看:42
本文介绍了无法连接到"localhost"上的邮件服务器端口587,请验证您的"SMTP"和"smtp_port"在php.ini中设置或在wamp服务器中使用ini_set()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i am using simple send email in php and get this error

警告:mail()[function.mail]:无法连接到位于以下位置的邮件服务器在"localhost"端口587上,验证您的"SMTP"和"smtp_port"设置是否位于php.ini或在中使用ini_set()

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use 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
  }
?>

推荐答案

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

SMTP server is required for sending emails. You need to mention SMTP host and SMTP port in php.ini file. If your config is proper then the mail function will work. There are various SMTP servers are available. You can search for them.

这篇关于无法连接到"localhost"上的邮件服务器端口587,请验证您的"SMTP"和"smtp_port"在php.ini中设置或在wamp服务器中使用ini_set()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆