下面的警告是什么意思?

发布于 2024-12-04 10:16:22 字数 869 浏览 1 评论 0原文

  <?php
   $to = "[email protected]";
   $subject = "Test mail";
   $message = "Hello! This is a simple email message.";
   $from = "[email protected]";
   $headers = "From:" . $from;
   mail($to,$subject,$message,$headers);
   echo "Mail Sent.";
 ?>

当我运行这些脚本时,出现这些错误

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost"
port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() 
in C:\xampp\htdocs\website\mail.php on line 7 

我现在必须做什么?谁能告诉我该怎么做?好的,我已经找到了该文件,但是我需要更新哪些字段,您能否建议我一些代码,以便我将其粘贴并保存?

  <?php
   $to = "[email protected]";
   $subject = "Test mail";
   $message = "Hello! This is a simple email message.";
   $from = "[email protected]";
   $headers = "From:" . $from;
   mail($to,$subject,$message,$headers);
   echo "Mail Sent.";
 ?>

When I run these script I get these error

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost"
port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() 
in C:\xampp\htdocs\website\mail.php on line 7 

What I have to do now? Could anyone tell me the way to do it ? Okay I have found that file but what are the fields I need to update could you suggest me some code so that i paste it these and save?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉城凉梦凉人心 2024-12-11 10:16:22

您必须使用有效的 smtp 服务器和电子邮件地址配置 php.ini。

You have to configure your php.ini with a valid smtp server and email address.

妄想挽回 2024-12-11 10:16:22

您需要将 PHP 配置为使用有效的 SMTP 服务才能发送 SMTP 电子邮件。这是一篇讨论该主题的文章

基本上,您的 PHP 实例的 SMTP 配置似乎使用默认值,该值指向 localhost。但您的本地计算机似乎没有运行 SMTP 服务。因此,您需要指向一台正在运行该服务器的服务器,并且该服务器允许您的应用程序使用该服务器。

You need to configure PHP to use a working SMTP service in order to send SMTP email. Here's an article that discusses the subject.

Basically, it appears that the SMTP configuration for your PHP instance is using default values, which point to localhost. But your local computer doesn't seem to be running an SMTP service. So you'll need to point is to a server that is running one, and one which your application is permitted to use.

站稳脚跟 2024-12-11 10:16:22

我想这个问题与您的其他问题相同...

如果是这样,我猜您正在尝试通过 GMail 的 SMTP 服务器发送电子邮件。他们的服务器需要身份验证,而 PHP 的邮件功能不支持身份验证。
正如我在另一个问题中回答你的那样,你可以使用 Zend_Mail 来执行此操作。您还可以使用 PEAR Mail,就像其他问题中的示例一样。
无论哪种方式,您都需要下载一些外部文件,将其包含在代码中并使用它。

I guess that this question is the same as your other question...

If so, I guess you are trying to send an email through GMail's SMTP server. Their server requires authentication, which PHP's mail function doesn't support.
As I answered you in the other question, you can use Zend_Mail to do this. You can also use PEAR Mail like in the example in the other question.
Either way you will need to download some external file, include it in your code and use it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文