wamp下使用php的mail()函数发送邮件问题

环境搭建:除了配置wamp之外,还需要一个邮件服务器,使用sendmail

sendmail下载:http://www.glob.com.au/sendmail/sendmail.zip 

配置:下载后得到sendmail.zip解压,然后以记事本的方式打开找到sendmial.ini并对下列选项进行编辑

smtp_server=smtp.qq.com(可以用gmail、163、qq)
auto = use SSL for port 465, otherwise try to use TLS//配置smtp_server端口使用ssl
smtp_port=25
[email protected](你的邮箱号)
auth_password=xxxx(你的邮箱密码)
smtp_ssl=auto
error_logfile=error.log(一般要设置调试日志,便于处理错误)
debug_logfile=debug.log
[email protected](用户名一般和邮箱号一致)
;default_domain=mydomain.com

php配置:右击wamp,找到php,打开php.ini

[mail function]
SMTP = localhost//邮件服务器的主机(这里是本机)
smtp_port = 25
sendmail_from = [email protected]//和sendmail.ini的邮箱号一致(否则会出现mail from address must be same as authorization user的错误,搞了老半天修改之后可以发送接收邮件)
sendmail_path = "F:\sendmail\sendmail.exe -t"//邮件服务器程序的路径

配置完之后重启wamp

在sendmail下的debug.log可查看:

17/03/01 17:11:46 >> To: [email protected]
17/03/01 17:11:46 >> Subject: Test email
17/03/01 17:11:46 >> X-PHP-Originating-Script: 0:php_61.php
17/03/01 17:11:46 >> From:from [email protected]
17/03/01 17:11:46 >>
17/03/01 17:11:46 >> hello this is a simple email
17/03/01 17:11:46 >> .
17/03/01 17:11:47 << 250 Ok: queued as
17/03/01 17:11:47 >> QUIT
17/03/01 17:11:47 << 221 Bye
17/03/01 17:11:47 ** Disconnecting from smtp.qq.com:25
17/03/01 17:11:47 ** Disconnected.
17/03/01 17:11:47 ** Disconnected.

你可能感兴趣的:(php,发送邮件,sendmail配置,wampServer使用)