解决错误“;PHPMailer错误:缺少扩展:openssl;


Resolve the error "PHPMailer Error: Extension missing: openssl"

我已删除;从php的php.ini以及apache文件夹中获取openssl。我仍然收到错误"PHPMailer错误:缺少扩展: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。

IIS上的PHP,

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

2( 取消注释(php.ini中的第910行(extension=php_opensl.dll

3( 重新启动IIS

对于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、端口号、身份验证。。。

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

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

在php.ini中,找到extension_dir = "ext"并将其更改为以下内容:extension_dir = "c:/php710/ext"你的道路可能会有所不同

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

在我的案例中,问题是"ext";目录:c:/Program files/php-5.4.36/exe

一旦改变,ext目录就变为";固体";path(简单地复制到一个路径内没有空格的地方(和phpmail (PHPMailer->SMTPSecure("tls"))工作得非常好!

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

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