PHPMailer 不工作 - 没有具体错误

PHPMailer not working - no specific error

我有一个不是我创建的旧网站,我注意到联系表不起作用,当您按发送时它没有任何反应。 在控制台中显示:

POST path of the mailer file 500 (Internal Server Error)

我找不到解决办法,所以如果有人能提供帮助,我将不胜感激。 这是代码:

<?php
require ('libphp-phpmailer/PHPMailerAutoload.php');
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$experience = $_POST['experience'];
$note = $_POST['note'];
$cv = $_POST['cv'];
$sended = 0;
if($firstname != '' && $lastname != '' && $email != '' && $phone != '' && $experience != '' && $note != '' && $cv != ''){
    switch($experience){
        case "1-5":
            $exp = "1 to 5 years";
            break;
        case "5-more":
            $exp = "more than 5 years";
            break;
        default:
            $exp = "nothing";
            break;
    }
    $body = "firstname: " . ucfirst($firstname) . "\n" . "lastname: " . ucfirst($lastname) . "\n" . "phone: " . $phone . "\n" . "Experience: " . $exp . "\n" . $note . "\n\n";
    $mailer = new PHPMailer();
    $mailer->IsSMTP();
    $mailer->Host = '---the email host----';
    $mailer->SMTPAuth = true;
    $mailer->Username = '---the right email---';
    $mailer->Password = '---email password---';
    $mailer->Port = 25;
    $mailer->Encoding = "base64";
    $mailer->CharSet = 'UTF-8';
    $mailer->AuthType = 'PLAIN';
    $mailer->setFrom($email, ucfirst($firstname) . ' ' . ucfirst($lastname));
    $mailer->AddReplyTo($email, ucfirst($firstname) . ' ' . ucfirst($lastname));
    $mailer->AddAddress('---the receiving address---');
    $mailer->isHTML(false);
    $mailer->ContentType = 'text/plain';
    $mailer->Subject = 'Contact form';
    $mailer->Body = $body;
    $mailer->AddAttachment($cv , 'Cv-' . $firstname . '-' . $lastname . '.pdf');
    if($mailer->Send()){
        $sended = 1;
    }
    $response = array(
        'sended'    => $sended
    );
    echo json_encode($response);
}
?>

我在文件顶部添加了 ini_set("display_errors", "On"); 并在 $mailer = new PHPMailer(); 之后添加了 mailer->SMTPDebug = 2; 然后我查看了浏览器工具箱的网络部分中的错误。 我发现错误在行中:

require ('libphp-phpmailer/PHPMailerAutoload.php');

因为 PHPMailerAutoload 不存在所以我删除了该行并通过 FTP 在我的网站上传了 PHPMailer 文件(下载 here),然后我在我的开头添加了这些行代码:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';