Php 通过access url发送的邮件,但在使用批处理文件运行时SMTP Connect()失败

Php 通过access url发送的邮件,但在使用批处理文件运行时SMTP Connect()失败,php,windows,batch-file,gmail,phpmailer,Php,Windows,Batch File,Gmail,Phpmailer,我对批处理文件有问题 如果我访问:http://localhost:8080/cron/cron.php 我收到了一封邮件,邮件是通过Gmail发送的 这是我的cron.php <?php require_once 'simplehtmldom\simple_html_dom.php'; require_once 'sites.php'; require_once 'send_mail.php'; ini_set('display_errors','on'); foreach ($s

我对批处理文件有问题

如果我访问:
http://localhost:8080/cron/cron.php
我收到了一封邮件,邮件是通过Gmail发送的

这是我的
cron.php

<?php   
require_once 'simplehtmldom\simple_html_dom.php';
require_once 'sites.php';
require_once 'send_mail.php';
ini_set('display_errors','on');
foreach ($site_list as $name => $link){
    $command = "C:\\Python27\\python C:\\webcheck\\webcheck.py -o C:\\wamp\\www\\cron\\reports\\$name $link";   
    $output =   shell_exec($command);   
    $log_file = "C:\\wamp\\www\\cron\\log.txt";
    $fh = fopen($log_file,'w') or die('can not open file');
    fwrite($fh, $output);
    fclose($fh);
}


/*Scan folder for reporting */
$path = 'C:\\wamp\\www\cron\\reports\\';
$msg = '';
foreach (new DirectoryIterator($path) as $fileInfo) {
    if($fileInfo->isDir() && !$fileInfo->isDot()) {
        // Do whatever
        $webcheck = $fileInfo->getFilename() ;
        $html = file_get_html($path.$webcheck.'\\badlinks.html');
        $es = $html->find('div[class="content"]', 0);
        $msg .="<h2>BADLINKS $webcheck</h2>";             
        $msg .= $es->innertext; // Some Content 
    }
}

$subj = $_subj; 
$to = $_to;
$from = $_from;
$name = $_name;

if (smtpmailer($to, $from, $name, $subj, $msg)) {
    echo 'Yeah, message send via Gmail';
} else {
    if (!smtpmailer($to, $from, $name, $subj, $msg, false)) {
        if (!empty($error)) echo $error;
    } else {
        echo 'Yep, the message is send (after doing some hard work)';
    }
}

?>
我转到
cmd
并键入
cron.bat

C:\wamp\bin\php\php5.3.5\php C:\wamp\www\cron\cron.php
我收到消息
邮件错误:SMTP连接()失败。

你知道吗


谢谢

记住cron作业将使用
PHP CLI
。而
phpcli
使用与Apache不同的
PHP.ini
文件

确保在另一个
php.ini文件中激活了所有必需的扩展名

我可以想象,
php\u smtp
扩展没有被激活

啊,我看到您正在使用WAMP,因此PHP.ini文件的
PHP CLI
版本将位于
c:\WAMP\bin\PHP\php5.x.y\PHP.ini

其中,由于Apache版本位于
c:\wamp\bin\Apache\apache2.x.y\bin\php.ini
中,如果需要比较您在Apache php中激活的扩展与在
php CLI中未激活的扩展