【问题标题】:send mail using xampp in php在 php 中使用 xampp 发送邮件
【发布时间】:2013-04-06 20:26:44
【问题描述】:

我看过很多视频,但不知道如何在 php 中send mail

我已经配置了smtp portserver 以及php.ini 文件以及sendmail.ini 文件,更改了auth_usernamepassword。但是,下面的代码还是不行!

<?php
    mail('xyz@gmail.com','Hello','Testing Testing','From:abc@gmail.com');
?>

我需要下载任何东西或更改 gmail 设置吗?

【问题讨论】:

  • 您是否尝试从localhost 发送邮件?
  • 是的,我正在使用 xampp!但我需要从我的 gmail 帐户发送的消息。我在 @Mr.Alien 上有互联网连接
  • 您应该真正使用经过验证的解决方案,例如 PHPMailer,因为如果您自己尝试这样做,您可能会遇到许多潜在的陷阱。看看phpmailer.worxware.com/index.php?pg=examplebgmail
  • 这里的伙计们可以解释更多,但我在邮件方面有更多的 linux 经验,但不要在没有正确知识的情况下尝试配置邮件服务器,因为如果你错过了一件事,您可能无法通过安全检查,并且您的外发邮件最终会成为垃圾邮件。使用其他为您配置的 PHP 解决方案,例如 PHPmailer

标签: php sendmail


【解决方案1】:

配置php.ini从你的服务器发送邮件非常简单,你只需正确配置php.ini and sendmail.ini即可。

首先你必须在你的 php.ini 文件中配置 sendmail_path 它应该指向带有正确标志的可执行 sendmail 文件

例如, ;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"(已经在您的 php.ini 文件中,只需删除注释即可) 和 sendmail_path 的其他分配需要注释。

配置好php.ini文件后需要配置sendmail.ini文件,在里面

首先smtp_server=mail.gmail.com(因为您想使用 gmail 作为 smtp 服务器), 第二个smtp_port=465(如果没有用,试试587),第三个auth_username= yourid@gmail.com auth_password=yourpassword

在此之后重新启动您的服务器。

【讨论】:

  • 这行得通。如果smtp_ssl=auto 不起作用,也许你可以尝试设置smtp_ssl=ssl。但我需要安装 apache 和 mysql 然后重新启动。不仅仅是从 xampp 控制面板运行。我不知道为什么。
  • 我一直在玩 Mercury,这是我需要的解决方案。希望我昨天找到了这个
猜你喜欢
  • 2015-12-16
  • 1970-01-01
  • 2012-12-15
  • 2015-01-05
  • 2014-07-29
  • 1970-01-01
  • 2015-07-03
  • 2013-01-31
相关资源
最近更新 更多