【问题标题】:Resolve the error "PHPMailer Error: Extension missing: openssl"解决错误“PHPMailer 错误:缺少扩展名:openssl”
【发布时间】:2021-10-17 16:29:16
【问题描述】:

我已经删除了;对于 php.ini 中的 openssl 以及 apache 文件夹。我仍然收到错误“PHPMailer Error: Extension missing: openssl” 以下是php代码,我也设置了phpmailerautoload。

PHP 代码:

<?php
require "PHPMailerAutoload.php";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// or try these settings (worked on XAMPP and WAMP):
/*$mail->Port = 587;
$mail->SMTPSecure = 'tls';*/


$mail->Username = "vignesh*******45@gmail.com";
$mail->Password = "********";

$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true; // if you want to send a same email to multiple users. multiple emails will be sent one-by-one.

$mail->From = "vignesh*******45@gmail.com";
$mail->FromName = "Vignesh";

$mail->addAddress("vignesh*******45@gmail.com","User 1");

//$mail->addCC("user.3@ymail.com","User 3");
//$mail->addBCC("user.4@in.com","User 4");

$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";

if(!$mail->Send())
    echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
    echo "Message has been sent";
?>

请帮助我解决错误。我也在 wampserver 中启用了 openssl。

【问题讨论】:

  • 错误消息说您缺少 openssl 扩展...您是否仔细检查过? aka,您是否编辑了正确的 ini 文件?
  • 也检查这里,可能会有一些提示:stackoverflow.com/questions/3477766/…
  • 编辑php.ini文件,去掉";"在“;extension=php_openssl.dll”

标签: php phpmailer


【解决方案1】:

IIS 上的 PHP,

1) 打开 (php安装目录)php.ini

2) 取消注释(~ php.ini 中的第 910 行) 扩展=php_openssl.dll

3) 重启 IIS

【讨论】:

  • 不,没有用。这些建议都没有奏效。我使用的是 Windows 10 和 PHP 7.4.10
【解决方案2】:

对于 Windows + Apache:

在 PHP.INI 中,取消注释 extension=php_openssl.dll

在 Apache\bin 中,添加 libeay32.dllssleay32.dll。 (跳过这一步会导致 Apache 启动两次说The ordinal 3906 could not be located in the dynamic link library LIBEAY32.dll.

重启 Apache。

下一步是让 SSL 工作 - TLS 与 SSL、端口号、身份验证......

【讨论】:

    【解决方案3】:

    在您的php.ini 文件中将;extension=php_openssl.dll 更改为extension=php_openssl.dll。 然后重新启动您的网络浏览器和 wamp/xampp 服务器。希望这会有所帮助。

    【讨论】:

      【解决方案4】:

      除了您所做的和@Bilbo 所说的之外,您可能希望将 php.ini 中的值形式 extension_dir 更改为绝对路径(而不是相对默认值)。不知道为什么,但这对我有用。

      在您的 php.ini 中找到 extension_dir = "ext" 并将其更改为:extension_dir = "c:/php710/ext"您的道路可能会有所不同!

      【讨论】:

        【解决方案5】:

        1)打开(php安装目录)php.ini
        提示:如果找不到您的 php.ini,您可以创建一个 php 文件并按如下方式运行:

        $inipath = php_ini_loaded_file();
         if ($inipath) {
              echo 'Loaded php.ini: ' . $inipath;
         } else {
              echo 'A php.ini file is not loaded';
         }
        

        这会告诉你你的 php.ini 在哪里,或者如果你没有加载一个。
        提示:如果需要,php 会附带一个生产和开发 php.ini。

        2) 取消注释(~ php.ini 中的第 910 行)
        7.4.2 之前:extension=php_openssl.dll
        7.4.2:extension=openssl

        3) 取消注释 extension_dir = "ext"(~php.ini 中的第 761 行)

        4) 重启 IIS

        【讨论】:

          【解决方案6】:

          在我的情况下,问题是“ext”目录路径中的空格:c:/Program files/php-5.4.36/exe

          一旦更改,ext dir 将变为“实心”路径(只需复制到路径内部没有空格的地方) 并且 phpmail (PHPMailer-&gt;SMTPSecure("tls")) 工作得非常好!

          显然在 php.ini 文件中,extension=php_openssl.dll 行要取消注释!

          奇怪的是,在这个工作完成后,命令行脚本的执行只有在重新启动命令 shell (cmd) 后才能恢复。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2018-08-11
            • 2016-02-14
            • 2015-03-05
            • 2016-06-19
            • 2015-12-18
            • 2014-09-24
            • 2018-05-22
            相关资源
            最近更新 更多