怎么在Windows系统中安装sendmail并且使用PHP mail函数?

2024-11-06 13:47:08
推荐回答(1个)
回答1:

php mail()函数windows能用需要安装sendmail
1.载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
用sendmail结合其smtp服务器smtp.gmail.com实现发邮件现部邮箱都要求smtp验证所要sendmail.ini加入用户名密码

php.ini配置 (用gmail邮箱例)
[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 25
; For Win32 only.
sendmail_from = zmacro@gmail.com
; For Unix only. You may supply arguments as well (default: sendmail -t -i).
sendmail_path = C:\PHP\sendmail\sendmail.exe -t
配置三项smtp、smtp_portsendmail_path

sendmail.ini配置
[sendmail]
; you must change mail.mydomain.com to your smtp server
smtp_server=smtp.gmail.com
smtp_port=25
auth_username=yourusername
auth_password=yourpassword
force_sender=zmacro@gmail.com
; default_domain=mydomain.com
sendmail网用xampp面直接带
同虚拟主机httpd.conf加句