基于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正在运行。
答案 0 :(得分:0)
在PHP 7上,取消对第921行的php.ini文件中的extension=php_openssl.dll
的注释。还请检查一下,在1945行附近的"css.colorDecorators.enable": false
下方没有注释。