学习NO.1 发表于 2016-7-7 11:43:55

如何在Windows系统中安装sendmail使用PHP mail函数

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邮箱例)

; 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配置

; 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加句
<directory d:/www/users/username> php_admin_value sendmail_path ‘C:\PHP\sendmail\sendmail.exe -t zmacro@gmail.com’</directory>
邮件址用户邮件址随便添

------------------------

测试文件mail_test.php
<?
if(mail("yourname@sina.com","测试","测试邮件"))
{
echo "发送功";
}
else{
echo "发送失败";
}
?>
页: [1]
查看完整版本: 如何在Windows系统中安装sendmail使用PHP mail函数