本文介绍了无法从localhost / xampp发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无法在mail.google.com端口587连接到邮件服务器,请在 php.ini 中验证您的SMTP和smtp_port设置,或使用 ini_set )
我将xampp php.ini和sendmail.ini文件配置为使用我的Gmail帐户从我的PHP脚本发送电子邮件。我正在使用xampp。改变了我的php.ini中的[mail function]部分后,看起来像这样(为简单起见,我已删除了注释大纲)
[ mail功能]
SMTP = mail.google.com
smtp_port = 587
mail.add_x_header =关
和我的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 = **** ******
那么我错过了什么?为什么我收到这个错误? 解决方案
你正在为Gmail使用错误的SMTP设置。正确的是:
在php.ini中
[mail函数]
; SMTP = localhost
; sendmail_from = [email protected]
sendmail_path =c:\ sendmail \ sendmail.exe -t -i
在sendmail.ini中
[sendmail]
smtp_server = smtp.gmail.com
smtp_port = 587
smtp_ssl = tls
[email protected]
auth_password = **** ******
记住:如果您启用了,您必须创建特定于应用程序的密码。
Failed to connect to mailserver at "mail.google.com" port 587, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
I configured my xampp php.ini and sendmail.ini file to use my Gmail account for sending email from my PHP script. i am using xampp. after changing the [mail function] part of my php.ini looks like this (i have deleted commented outlines for simplicity)
[mail function]
SMTP = mail.google.com
smtp_port = 587
mail.add_x_header = Off
and my sendmail.ini file looks like this
[sendmail]
smtp_server=mail.google.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=babar+gmail.com
auth_password=**********
So what have I missed? Why am I getting this error?
解决方案
You are using wrong SMTP settings for gmail. The correct ones are:
In php.ini
[mail function]
;SMTP = localhost
;sendmail_from = [email protected]
sendmail_path = "c:\sendmail\sendmail.exe -t -i"
In sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
[email protected]
auth_password=**********
Remeber: If you have enabled 2 step authentication, you have to create an application specific password.
这篇关于无法从localhost / xampp发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!