Home  >  Article  >  Backend Development  >  PHP调用.bat文件的有关问题

PHP调用.bat文件的有关问题

WBOY
WBOYOriginal
2016-06-13 10:35:36913browse

PHP调用.bat文件的问题 急求高手指教
我用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 !!!!"
  );
   
  MIME::Lite->send('smtp', "smtp.sina.com", Timeout=>90,Port =>"25"); 
  $Message->send();  

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

------解决方案--------------------

PHP code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn