繁体   English   中英

无法从localhost / xampp发送邮件

[英]Can't send mail from 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 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=**********

那么我错过了什么? 为什么我收到此错误?

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

在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步验证 ,则必须创建应用程序专用密码。

将smtp_ssl = auto设置为smtp_ssl = true

因为谷歌的smtp服务器需要ssl

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM