如何在Windows系统中安装sendmail使用PHP mail()函数
思韵闪耀
2013-03-18
0
php mail()函数在windows不能用,需要安装sendmail。
1.从http://glob.com.au/sendmail/下载sendmail.zip
2.解压到C:下,例如C:PHPsendmail,最好短路径,长路径名有可能产生问题。
3.修改php.ini如下
sendmail_path "C:PHPsendmailsendmail.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:PHPsendmailsendmail.exe -t”
就配置三项,smtp、smtp_port和sendmail_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里加上这样一句
<directory d:/www/users/username>   php_admin_value sendmail_path ‘C:PHPsendmailsendmail.exe -t zmacro@gmail.com’</directory>
此邮件地址为用户的邮件地址,随便添。

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

测试文件mail_test.php
<?
if(mail("yourname@sina.com","测试","测试邮件"))
{
echo "发送成功!!";
}
else{
echo "发送失败!!";
}
?>


【版权声明】
本站部分内容来源于互联网,本站不拥有所有权,不承担相关法律责任。如果发现本站有侵权的内容,欢迎发送邮件至masing@13sy.com 举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

相关内容

将IIS设置克隆到新服务器...
将IIS设置克隆到新服务器的最佳方法是使用IIS配置文件。以下是详...
2025-06-06
搭建Git服务器及本机克隆...
Git是什么?Git是目前世界上最先进的分布式版本控制系统。SVN...
2025-03-17
ubuntu环境下搭建gi...
操作环境:服务器:Ubuntu 24.04.2 LTS+git 2...
2025-03-17
Windows serve...
Windows server2019安装Intel I219-V网...
2025-01-15
windows下安装Pre...
windows下安装PrestaShop报错Unable to g...
2024-06-16
Windows通过命令对文...
Windows通过命令对文件夹赋权要在Windows上使用命令行(...
2024-04-30

热门资讯

Discus X论坛配置sen... Discuz x2.5 后台邮件设置方法其实和X2/x1.5基本一样,但很多同学都不注意一些细节,比...
redhat Linux系统配... 1 .检查Send Mail 的安装包 [root@sql root]# rpm -qa | gre...
使用Sendmail的反垃圾邮... 在最近几年,无处不在的垃圾邮件已使得所有邮件箱不堪重负,不断地需要工具以抗击这一无穷尽的垃圾邮件流。...