php中使用mail()函数不能发邮件的解决方法:首先下载sendmail并解压;然后打开php.ini配置文件,编辑“mail function”模块;最后编辑sendmail.ini配置文件,设置邮箱信息即可。
原因分析:
mail()函数在windows系统中不能直接使用,需要下载sendmail。
(推荐教程:php图文教程)
解决方法:
首先下载sendmail,进行解压,路径自定义,例如:E:\\\\sendmail;
然后在php.ini配置文件中加入以下配置(以163邮箱为例);
复制[mail function]
SMTP = smtp.163.com
smtp_port =25
sendmail_from =4u4v@163.com
sendmail_path ="E:\\\\sendmail\\\\sendmail.exe -t"
(视频教程推荐:php视频教程)
然后修改sendmail.ini文件;
复制smtp_server=smtp.163.com//这里是配置对应的163的smtp
smtp_port=25
auth_username=username //邮箱用户名
auth_password=password //邮箱密码
force_sender=username@163.com //你的邮箱全名 用户名@163.com
完成!