Windows 下 用 php 【mail()】函数发送邮件 (本地环境)

php mail()函数在windows不能用,需要安装sendmail。

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

 

php.ini配置

SMTP = localhost
smtp_port = 25
sendmail_from = mail@ijophy.com #这个可以不用,因为函数里面有填写
sendmail_path = "E:\www\php-5.3.18\sendmail\sendmail.exe -t"

sendmail.ini配置

smtp_server=smtp.live.com
smtp_port=25
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username= 发信人
auth_password= 发信人密码
force_sender= 强制_寄信人 (必填,不然错误日志会提示找不到)

 

原文地址:https://www.cnblogs.com/zhiqixue/p/2776920.html