windows下用sendmail配置php的mail函数
php自带的mail函数,由于使用无验证的smtp服务,大部分服务商已不支持,解决办法有两个:
一是自己搭建smtp服务器;
二是使用第三方smtp服务器和新的sendmail函数,使用第二种方法:
1、首先去http://glob.com.au/sendmail/下载sendmail.zip
2、解压sendmail.zip到某个文件夹下,比如D:\sendmail\,路径一定要短!!!否则会出bug!!!
3、配置php.ini
找到[mail function]部分,只留下下面两句话,其他注释掉
sendmail_path = "D:\sendmail\sendmail.exe -t" //将mail函数路径定义到自己的sendmail函数上
mail.add_x_header = On
4、配置sendmail.ini
smtp_server=smtp.163.com //或其他smtp服务器,有可能需要用户开通smtp服务
smtp_port=25
auth_username=xxx@xxx.com //用户名
auth_password=xxxxxxxx //密码
5、重启Apache服务器,使用mail函数就可以发送成功啦