我写使用PHPMailer的PHPMailer的在浏览器中工作,但在命令提示符下不工作
include 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug = 1;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = '[email protected]';
$mail->Password = 'password';
$mail->SetFrom('[email protected]', 'Admin');
$mail->AddReplyTo('[email protected]', 'Name');
$mail->AddAddress('[email protected]');
$mail->Subject = 'Active email';
$mail->MsgHTML('Click the link to active');
$mail->Send();
当我使用浏览器,它可以发送邮件,但在命令提示符代码发送邮件,
php path_to_file
是不工作,错误的是:
SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport ssl"....
你可能使用不同的php.ini对于CLI,比较'php -i'和'<?php phpinfo();' –
的输出,如果有两个文件,如何为CLI和http服务器使用一个文件? – Hoclamweb