我正在尝试使用phpmailer发送电子邮件并收到标题中提到的错误。我正在使用XAMPP用于apache服务器。 我几乎搜索了谷歌和各地的所有链接,但没有任何对我有用。
<?php
ini_set('display_errors', 1);
require 'autoload.php';
require 'class.phpmailer.php';
//require 'class.smtp.php';
$mail = new PHPMailer;
$mail->IsSMTP();
//$mail->SetLanguage("en", 'language');
$mail->Mailer = "smtp";
//$mail->SMTPSecure = "tls";
$mail->Port = 465;
$mail->SMTPDebug = 2;
$mail->SMTPAuth=False;
$mail->Host="smtp.gmail.com";
$mail->Username = "email@gmail.com";
$mail->Password = "password";
//$mail->setFrom("email@gmail.com");
$mail->From = "email@gmail.com";
$mail->addAddress('email@gmail.com','Rishabh Goel');
$mail->isHTML(false);
$mail->Subject = 'First Subject';
$mail->Body = 'Mail body in HTML';
$mail->AltBody = 'This is the plain text version of the email content';
/*try{
$mail->Send();
echo "Thanks. Bug report successfully sent.
We will get in touch if we have any more questions!";
} catch(Exception $e){
//Something went bad
echo "Mailer Error: - " . $mail->ErrorInfo;
}*/
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo "Message has been sent successfully";
}
?>