访问URL发送的邮件,但使用批处理文件运行时,SMTP Connect()失败

I have a problem with batch file

if I access: http://localhost:8080/cron/cron.php I got email sent with message Yeah, message send via Gmail

this my 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\eports\\$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\eports\\';
$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)';
    }
}

?>

But with this cron.bat

C:\wamp\bin\php\php5.3.5\php C:\wamp\www\cron\cron.php

I go to cmdand type cron.bat

I got messsage Mail error: SMTP Connect() failed.

Do you have any idea?

Thanks

Remember that cron jobs will be using the PHP CLI. And the PHP CLI uses a different php.ini file to Apache.

Make sure you have all the required extension activated within this other php.ini file.

I would imagine the php_smtp extension is not activated.

Ahh I see you are using WAMP so the PHP CLI version of the php.ini file will be in c:\wamp\bin\php\php5.x.y\php.ini.

Where as the Apache version is in c:\wamp\bin\apache\apache2.x.y\bin\php.ini if you need to compare which extension you have activated in Apache PHP to those not activated in the PHP CLI