【问题标题】:Can't send mail from localhost/xampp无法从 localhost/xampp 发送邮件
【发布时间】:2013-07-15 23:53:24
【问题描述】:

无法在“mail.google.com”端口 587 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用ini_set()

我将我的 xampp php.ini 和 sendmail.ini 文件配置为使用我的 Gmail 帐户从我的 PHP 脚本发送电子邮件。我正在使用 xampp。更改我的 php.ini 的 [mail function] 部分后,看起来像这样(为简单起见,我删除了注释大纲)

[mail function]
SMTP = mail.google.com
smtp_port = 587
mail.add_x_header = Off

我的 sendmail.ini 文件看起来像这样

[sendmail]
smtp_server=mail.google.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=babar+gmail.com
auth_password=**********

那么我错过了什么?为什么会出现此错误?

【问题讨论】:

  • 听起来像是网络连接问题。也许您的 Internet 提供商不允许在该端口上进行传出连接?
  • 请多说一些。如何摆脱这个问题。

标签: php gmail xampp


【解决方案1】:

将 smtp_ssl=auto 设置为 smtp_ssl=true

因为google的smtp服务器需要ssl

【讨论】:

  • 我已经尝试过了,但没有奏效。问题依然存在。
【解决方案2】:

您为 gmail 使用了错误的 SMTP 设置。正确的是:

在 php.ini 中

[mail function]
;SMTP = localhost
;sendmail_from = me@example.com
sendmail_path = "c:\sendmail\sendmail.exe -t -i"

在 sendmail.ini 中

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
auth_username=me@example.com
auth_password=**********

记住:如果您启用了2 step authentication,您必须创建一个应用程序专用密码。

【讨论】:

  • 问题依然存在。请您粘贴 sendmail.ini 文件的内容。我坚持下去。
  • @buet_baba 哎呀!我之前给你错误的答案。现在试试这个。它已经过测试并在我的 PC 上运行。
  • 不,它不起作用。你能把你的php.ini文件和sendmail文件夹发给我吗?我做不到。还有一件事,你用的是哪个版本的 xampp?
  • 它在这里工作。可能是你身边的其他问题。也许是防火墙
  • 您知道防火墙如何阻止我的应用程序处理吗?
猜你喜欢
  • 2012-01-21
  • 2016-05-30
  • 2018-03-08
  • 2016-05-13
  • 2017-12-06
  • 2015-12-16
  • 1970-01-01
  • 2014-07-29
  • 2012-05-07
相关资源
最近更新 更多