我使用 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 = 'example1@gmail.com';
$mail->Password = 'password';
$mail->SetFrom('example2@gmail.com', 'Admin');
$mail->AddReplyTo('example@yahoo.com', 'Name');
$mail->AddAddress('xample3@gmail.com');
$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"....