在Windows下配置PHP中的sendmail图文教程
思韵闪耀
2013-03-19
0
用sendmail来发批量邮件功能。
如果不用xampp的话,去下载个,如果用,刚按下面几步配置即可。
1.使用sendmail 修改 D:\xampp\sendmail\sendmail.ini



具体内容是:
[sendmail]
smtp_server=mail.test.com
; smtp port (normally 25)
smtp_port=25
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
default_domain=test.com
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username=info@test.com
auth_password=testpassword
配置以上几个参数即可
2.使用php sendmail修改 D:\xampp\apache\bin\php.ini 修改如下:


具体内容如下:
[mail function]
; For Win32 only.
SMTP = mail.test.com
smtp_port = 25
; For Win32 only.
sendmail_from = info@test.com
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "D:\xampp\sendmail\sendmail.exe -t"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
3. 重新启动 Apache,設定完畢!
4. 使用php sendmail測試mail()功能


<?php
$now = date('Y-m-d h:i:s');
$from_name = '测试寄件人';
$from_email = 'info@test.com';
$headers = "From: $from_name <$from_email>";
$to = 'to@test.com';  //收件人邮件地址
$body = "嗨, \n 这是一封测试邮件来自 $from_name <$from_email>.";
$subject = "[$now] 测试邮件发送";
if (mail($to, $subject, $body, $headers)) {
echo 'success!';
} else {
echo 'fail…';
}
?>
这样,Windows下使用php sendmail配置就顺利完成了!
执行完之后,再看D:\xampp\sendmail\目录,会多出几个文件


具体一些内容大家试完自己看吧,error.log还是能有帮助的


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

相关内容

Windows Servi...
Supported platformsWinSW 3 c...
2026-04-16
通过Windows服务实现...
使用工具:NSSM (Non-Sucking Service Ma...
2026-04-16
Windows 系统中创建...
要在 Windows 系统中创建一个‌睡眠快捷键‌,可通过创建桌面...
2026-03-27
windows serve...
问题现象:升级到server2022系统后重启服务器每次都需要登录...
2026-03-22
Windows系统下卸载O...
以下是Windows系统下卸载OpenClaw的完整步骤: ...
2026-03-13
openclaw部署到本地...
在 Windows 10 个人电脑上部署 OpenClaw(202...
2026-03-12

热门资讯

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