【发布时间】:2022-01-20 20:31:23
【问题描述】:
附加代码在我们的服务器上完美运行。
仅供参考,注释掉的 require() 语句会加载一个文件,该文件包含其后的每一行内容。
当我取消注释 require() 语句,然后注释掉它下面的相同内容时,就会出现问题。
当我这样做时,突然 PHPMailer 对象拒绝实例化。
我对所有文件/文件夹都有双重检查权限,它们都很好。
这真是让人头疼。
帮助!
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require( CLASSES . "src/PHPMailer.php" );
require( CLASSES . "src/SMTP.php" );
require( CLASSES . "src/Exception.php" );
// require( 'receipt_email.php' );
$email = new PHPMailer();
try
$email->IsSMTP();
$email->SMTPDebug = 0;
$email->SMTPAuth = TRUE;
$email->Host = SERVER_NAME;
$email->SMTPSecure = "tls";
$email->Port = "587";
$email->Username = MAIL_ACCTNAME;
$email->Password = MAIL_PASSWORD;
$email->FromName = "do_not_reply@lcus.edu";
$email->From = "LCUonline";
$email->Subject = "TEST MESSAGE";
$email->Body = "TEST MESSAGE BODY";
$email->AddAddress( "developer@lcus.edu", "Dr. Steve Willis" );
echo $email->Send() ? "SUCCESS" : "FAILED";
}
catch( Exception $e ) {
echo "Message could not be sent. Mailer Error: {$email->ErrorInfo}";
}
unset( $email );
【问题讨论】: