PHP调用.bat文件的问题 急求高手指教

时间:2021-10-15 08:03:48
我用perl写了一个bat文件,功能就是简单的邮件发送。现在我想在PHP里面调用这个bat,我试着用system和exec调用:
system('cmd\C C:\Documents and Settings\nshi\Bureau\dev redmine-sugar\phpmail.bat',$result);
//exec('cmd\C C:\Documents and Settings\nshi\Bureau\dev redmine-sugar\phpmail.bat',$result);
echo "result : ".$result;

结果是用system命令得到的输出结果是 result : 1
而exec输出结果是 result : Array
而且2次的邮件都没有发送成功。

我bat文件的代码就一行
perl.exe phpmail.pl

其中phpmail.pl的代码:
use Net::SMTP;
use MIME::Lite;              
               my $Message = MIME::Lite->new(
               From =>"123\@sina.com",  
               To =>"456\@sina.com",
               Subject =>"SUJET",
               Type    =>'multipart/related'
               );
               
               $Message->attach
               (
               Type =>'text/html',
               Data =>"MESSAGE <b>!!!!</b>"
               );
               
               MIME::Lite->send('smtp', "smtp.sina.com", Timeout=>90,Port =>"25"); 
                  $Message->send();   

在windows命令行直接运行bat文件的话,邮件成功发送,但是用php调用就发生了上述的情况,邮件都没有被成功发送。
请问有没有前辈能帮我看看到底是哪出了问题?
PS:或者哪位高手能讲讲如果用PHP发送邮件?用smtp的
先谢谢了

3 个解决方案

#1


我bat文件的代码就一行 
perl.exe phpmail.pl 
改成绝对路径试试

#2



<?php
system('cmd /c c:\test.bat');

///////

system('perl.exe d:\test.pl'); //perl.exe必须在系统环境变量中
?>

#3


楼主怎么解决的啊 我也是php调bat没反应

#1


我bat文件的代码就一行 
perl.exe phpmail.pl 
改成绝对路径试试

#2



<?php
system('cmd /c c:\test.bat');

///////

system('perl.exe d:\test.pl'); //perl.exe必须在系统环境变量中
?>

#3


楼主怎么解决的啊 我也是php调bat没反应