我有一个(也许是愚蠢的)问题。由于我是新手并且已经尝试了几种解决方案,所以我现在在这里寻求有关脚本的帮助。
我正在使用这个脚本来生成 LetsEncrypt 证书。它已经工作了五年多,但今天在订购过程中通过终端提示我以下消息:
550: Failed to spawn mail-process (ec:16) Error: Class "PHPMailer\PHPMailer\Exception" not found
这是触发的脚本的相关部分:
###sending it as email:
##########################################################
# sendCertificate
##########################################################
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include('PHPMailer.php');
function sendCertificate($myemail) {
global $argv;
global $account_number;
$email = new PHPMailer();
$email->setFrom($myemail); //Name is optional
$email->Subject = 'ssl certificate files';
$email->Body = "
https://kis.hosteurope.de/administration/webhosting/admin.php?menu=6&mode=ssl_list&wp_id=$account_number
Zertifikat: fullchain.pem
Key: cert_private_key.pem
";
$email->addAddress($myemail);
$file_to_attach = __DIR__ . '/'.$argv[3];
$email->addAttachment($file_to_attach , $argv[3]);
$file_to_attach = __DIR__ . '/fullchain.pem';
$email->addAttachment($file_to_attach , 'fullchain.pem');
$sent = $email->send();
if($sent) {
echo "sending certificates by mail ... OK\n";
}
else {
echo "sending certificates by mail ... ERROR\n";
print_r( error_get_last() );
}
}
sendCertificate($argv[1]);
?>
顺便说一句,我在 GoDaddy 托管的网络空间上。服务器是 PHP 8.1。该脚本自几周前运行以来一直没有更改。
谢谢!
最好
我尝试将 PHPMailer.php 更新到最新版本。
我通过更新 PHP Mailer、创建新的 SMTP 帐户并更新脚本解决了问题:
// Manually loading the necessary PHPMailer classes
require 'PHPMailer.php';
require 'SMTP.php';
require 'Exception.php';
function sendCertificate($myemail) {
global $argv;
global $account_number;
global $domain_id;
$email = new PHPMailer();
try {
//Server settings
$email->isSMTP(); // Send using SMTP
$email->Host = '+++'; // Set the SMTP server to send through
$email->SMTPAuth = true; // Enable SMTP authentication
$email->Username = '+++'; // SMTP username
$email->Password = '+++; // SMTP password
$email->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
$email->Port = 587; // TCP port to connect to
// Recipients and content
$email->setFrom($myemail); // Name is optional
$email->Subject = '+++';
$email->Body = "
https://kis.hosteurope.de/administration/webhosting/admin.php?menu=6&wp_id=$account_number&mode=sslupload&v_id=$domain_id
Certificate: fullchain.pem
Key: cert_private_key.pem
";
$email->addAddress($myemail);
$file_to_attach = __DIR__ . '/' . $argv[3];
$email->addAttachment($file_to_attach, $argv[3]);
$file_to_attach = __DIR__ . '/fullchain.pem';
$email->addAttachment($file_to_attach, 'fullchain.pem');
if ($email->send()) {
echo "Sending certificates by email ... OK\n";
} else {
echo "Sending certificates by email ... ERROR\n";
}
} catch (Exception $e) {
echo "Sending certificates by email ... ERROR: ", $email->ErrorInfo, "\n";
} catch (\Exception $e) {
echo "General error: ", $e->getMessage(), "\n";
}
}
sendCertificate($argv[1]);