【PHP】Windows下配置用mail()发送邮件

ZZ:解决windows系统下php.ini邮件配置正确不发送邮件的问题

php mail()函数在windows不能用,需要安装sendmail,假如是用的XAMPP,则已经下载好,不需要重新下载~

1.从http://glob.com.au/sendmail/下载sendmail.zip 
2.解压到C:下,例如C:phpsendmail,最好短路径,长路径名有可能产生问题。 
3.修改php.ini如下 
sendmail_path = "C:wampsendmailsendmail.exe -t" 
4.根据你自己的配置环境修改sendmail.ini。 
第一次最好启用debug.log_file,error_logfile,以查看sendmail是否生效。 
5.重启apache 

用sendmail结合其它的smtp服务器,如smtp.163.com来实现发邮件。现在大部分邮箱都要求smtp验证,所以要在sendmail.ini中加入用户名和密码。 

php.ini配置:就配置三项,smtp、smtp_port和sendmail_path  (以用163邮箱为例)

[mail function] 
; For Win32 only. 
SMTP = smtp.163.com 
smtp_port = 25 
; For Win32 only. 
sendmail_from = 4u4v@163.com 
; For Unix only. You may supply arguments as well (default: “sendmail -t -i”). 
sendmail_path = “D:xamppsendmailsendmail.exe -t”

注意:在php.ini中,有些配置前面原先是加了分号的,要去掉!

sendmail.ini配置 :

[sendmail] 
; you must change mail.mydomain.com to your smtp server 
smtp_server=smtp.163.com 
smtp_port=25 
auth_username=yourusername 
auth_password=yourpassword 
force_sender=yourusername@163.com 

这样配置完成以后,就可以使用mail函数了~~~

原文地址:https://www.cnblogs.com/lqminn/p/3468357.html