[英]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.