php 解决错误“PHPMailer Error: Extension missing: openssl”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30284409/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Resolve the error "PHPMailer Error: Extension missing: openssl"
提问by Vignesh Anandakumar
I've removed ; for openssl from php.ini at php as well as apache folder. I still get the error "PHPMailer Error: Extension missing: openssl" The following is the php code and I've setup phpmailerautoload too.
我已经删除了;对于来自 php.ini 在 php 以及 apache 文件夹中的 openssl。我仍然收到错误“PHPMailer 错误:缺少扩展名:openssl” 以下是 php 代码,我也设置了 phpmailerautoload。
PHP CODE:
代码:
<?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*******[email protected]";
$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*******[email protected]";
$mail->FromName = "Vignesh";
$mail->addAddress("vignesh*******[email protected]","User 1");
//$mail->addCC("[email protected]","User 3");
//$mail->addBCC("[email protected]","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";
?>
Please help me in resolving the error. I've enabled openssl in wampserver too.
请帮助我解决错误。我也在 wampserver 中启用了 openssl。
回答by Arlan T
PHP on IIS,
IIS 上的 PHP,
1) Open (php install directory)php.ini
1)打开(php安装目录)php.ini
2) Uncomment (~ line 910 in php.ini) extension=php_openssl.dll
2)取消注释(php.ini中的~第910行)extension=php_openssl.dll
3) Restart IIS
3)重启IIS
回答by Bilbo
For Windows + Apache:
对于 Windows + Apache:
In PHP.INI, un-comment extension=php_openssl.dll
.
在 PHP.INI 中,取消注释extension=php_openssl.dll
.
In Apache\bin, add libeay32.dll
and ssleay32.dll
. (Skipping this step causes Apache startup to twice say The ordinal 3906 could not be located in the dynamic link library LIBEAY32.dll.
)
在 Apache\bin 中,添加libeay32.dll
和ssleay32.dll
. (跳过这一步会导致Apache启动两次说The ordinal 3906 could not be located in the dynamic link library LIBEAY32.dll.
)
Restart Apache.
重新启动阿帕奇。
The next step is getting the SSL stuff working - TLS versus SSL, port number, authentication ...
下一步是让 SSL 工作 - TLS 与 SSL、端口号、身份验证......
回答by Verma Aman
change ;extension=php_openssl.dll
to extension=php_openssl.dll
in your php.ini
file.
then restart your webbrowser and wamp/xampp server. hope this helps.
在您的文件中更改;extension=php_openssl.dll
为。然后重新启动您的网络浏览器和 wamp/xampp 服务器。希望这可以帮助。extension=php_openssl.dll
php.ini
回答by user7363501
In addition to what you did and what @Bilbo said, you might want to change the value form extension_dir
in your php.ini to an absolute path (instead of the relative default). Not sure why, but that did the trick for me.
除了您所做的和@Bilbo 所说的之外,您可能还想将extension_dir
php.ini 中的值形式更改为绝对路径(而不是相对默认值)。不知道为什么,但这对我有用。
In your php.ini find and change extension_dir = "ext"
to something like this: extension_dir = "c:/php710/ext"
. Your path may vary!
在你的php.ini查找和更改extension_dir = "ext"
到是这样的:extension_dir = "c:/php710/ext"
。您的路径可能会有所不同!
回答by TheBoredMage
1) Open (php install directory) php.ini
Tip: If you can't find your php.ini you can create a php file and run it as follows:
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';
}
This will tell you where your php.ini or if you dont have one loaded.
Tip: php comes with a production and development php.ini if you need one.
这会告诉你你的 php.ini 在哪里,或者你是否没有加载。
提示:如果您需要,php 会附带一个生产和开发 php.ini。
2) Uncomment (~ line 910 in php.ini)
Pre 7.4.2: extension=php_openssl.dll
7.4.2: extension=openssl
2) 取消注释 (~ php.ini 中的第 910 行)
Pre 7.4.2: extension=php_openssl.dll
7.4.2:extension=openssl
3) Uncomment extension_dir = "ext"
(~line 761 in php.ini)
3) 取消注释extension_dir = "ext"
(php.ini 中的~第 761 行)
4) Restart IIS
4) 重启 IIS