这里是普通文章模块栏目内容页
在Windows下配置PHP中的sendmail图文教程
用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还是能有帮助的