我遇到了错误:发生了一些错误
当我单击刷新到in.php页面以测试发送电子邮件时-> 在浏览器中出现“发生了某些错误”,我不知道问题出在哪里
我需要帮助!
<?php
//include phpmailer.php
require("PHPMailer-master/src/PHPMailer.php");
require("PHPMailer-master/src/SMTP.php");
require("PHPMailer-master/src/Exception.php");
//create an instance of PHPMailer
$mail = new PHPMailer\PHPMailer\PHPMailer;
//set a host
$mail->Host = "smtp.gmail.com";
//set authentication to true
$mail->SMTPAuth = true;
//set login details for Gmail account
$mail->Username = "xxxxxx@gmail.com";
$mail->Password = "xxxxxxxxxx";
//set type of protection
$mail->SMTPSecure = "ssl"; //or we ca use TLS
//set a port
$mail->Port =465; //or 587 if TLS
//set subject
$mail->Subject = "Test email";
//set body
$mail->Body = "This is our body...";
//set who is sending an email
$mail->setFrom("xxxxxx@gmail.com","xxxxx");
//set where we are sending email
$mail->addAddress("xxxxxx@yahoo.com");
//send an email
if($mail->send()){
echo "mail is sent";
}
else {
echo "something wrong happened";
}
?>