使用php和Xampp发送邮件无法正常工作

时间:2015-11-15 10:13:06

标签: php apache email gmail

我曾尝试使用php和sendmail发送邮件。它看起来很简单,但我的配置似乎无法正常工作。

我的sendmail.ini

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=587

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

auth_username= my-address@gmail.com
auth_password= ***** (my pwd)

我的部分php.ini

; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

我的简单php

mail('xxxx@xxx.com', 'test msg', 'best messages', 'From:xxx@xxxx.com');

我的邮箱里没有收到任何内容。我还查看了垃圾邮件文件夹。 在sendmail和php.ini文件中进行配置之后,我重新启动了Xampp Apache,但没有任何改变。

我也试过端口:25或465或587

我是否犯了错误?

任何帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

您是否想要使用第三方邮件?喜欢php邮件? 这里phpmailer 。每当我在开发阶段我需要发送邮件时,我就会使用它。当我在实时服务器上时,我会切换回php邮件功能,它已经配置好了,就像你在本地机器上一样。希望有人帮忙。