缺少PHPMailer扩展:openssl

缺少PHPMailer扩展:openssl,php,ubuntu,openssl,phpmailer,Php,Ubuntu,Openssl,Phpmailer,根据PHPMailer提供的示例,我有以下脚本: use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; if($_POST){ $name = $_POST['name'];

根据PHPMailer提供的示例,我有以下脚本:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
if($_POST){
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $patrimonio = $_POST['patrimonio'];
    $serial = $_POST['serial'];
    $unidade=$_POST['unidade'];
    $endereco=$_POST['endereco'];
    $setor=$_POST['setor'];
    $telefone=$_POST['telefone'];
    $procedencia=$_POST['procedencia'];
    $equipamento=$_POST['equipamento'];    
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = gethostbyname("smtp.gmail.com");
$mail->Port = 587;
$mail->SMTPSecure = "tls";
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "myemail@gmail.com";
$mail->Password = "mypass";
$mail->setFrom("myemail@gmail.com", 'Gerador de OS');
$mail->addAddress($email, $name);
$mail->AddBCC('HelpDesk@gmail.com', $name);
$mail->Subject = "Abertura de OS";
$mail->Body=$message;
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "true";
}
}
即使这与最初的示例完全相同,我也无法让它工作

我得到的错误是:

Extension missing: openssl
Mailer Error: Extension missing: openssl
但服务器表示,使用以下命令一切正常:

php -i | grep -i openssl
结果是:

openssl

OpenSSL support => enabled

OpenSSL Library Version => OpenSSL 1.0.1 14 Mar 2012 

OpenSSL Header Version => OpenSSL 1.0.1 14 Mar 2012 Native 

OpenSSL support => enabled
这个服务器中有joomla,我可以确认OpenSSL正在运行


在PHP 7上,在第921行附近的PHP.ini文件中取消对扩展名=PHP\u openssl.dll的注释。还要检查1945行下方的
extension=php_openssl.dll
是否未注释。

在PHP7上,在921行附近的php.ini文件中取消注释
extension=php_openssl.dll
。另外,检查1945行下方的
extension=php\u openssl.dll是否未注释。

php-i
仅显示php CLI SAPI。您需要通过web服务器运行
phpinfo()
,查看它是否有不同的选项。Synchro,phpinfo()显示有关openssl的相同信息…IIRC,PHPMailer通过检查常量而不是ext本身来检查openssl的存在(针对安全模式问题)-看起来您使用的是一个非常旧的openssl版本,其中可能没有必要的常量。Synchro,您会推荐一些openssl版本吗?
php-i
仅显示php CLI SAPI。您需要通过web服务器运行
phpinfo()
,查看它是否有不同的选项。Synchro,phpinfo()显示有关openssl的相同信息…IIRC,PHPMailer通过检查常量而不是ext本身来检查openssl的存在(针对安全模式问题)-看起来您使用的是非常旧的openssl版本,其中可能不包含必要的常量。Synchro,您会推荐一些openssl版本吗?