dongzhou5344 2018-04-15 15:16
浏览 68

没有php.ini并使用默认的示例中断功能

I'm just starting out with PHP and my first task is to handle requests to a website by sending retrieved form data to a specified email address.

I've made a simple contact.php file which is called by the Submit button on the form. The data is being retrieved, and I have processed it with the following code:

<?php 

require_once('PHPMailerAutoload.php');

$errors = '';
$myemail = 'randomtext@gmail.com';
$mypassword = 'randomtext';

if(empty($_POST['fname'])  ||
   empty($_POST['lname']) ||
   empty($_POST['email']) ||
   empty($_POST['subject']) ||
   empty($_POST['message']))
{
    $errors .= "
 Error: all fields are required!";
}

$name = $_POST['fname'] . ' ' . $_POST['lname'];
$email_address = $_POST['email'];
$message = 'De : ' . $name . '
 Concerning : ' . $_POST['subject'] . 
'

' . $_POST['message']  ;
$subject = 'Query from website : ' . $_POST['subject'];

$mail = new PHPMailer();
$mail-> isSMTP();
$mail-> SMTPAuth = true;
$mail-> SMTPSecure = 'ssl';
$mail-> SMTPHost = 'smtp.gmail.com';
$mail-> SMTPDebug = 2;
$mail-> Port ='465';
$mail-> isHTML();
$mail-> UserName=$myemail;
$mail-> Password=$mypassword;   
$mail-> SetFrom = $myemail;
$mail-> Subject = $subject;
$mail-> AddAddress($myemail);
$mail -> Body = $message;

if( empty($errors))
{
    $mail -> Send();
}
else
print $errors;

?>

The mail is not being sent and the debugger throws this error: Extension missing: openssl

So I read elsewhere here that I needed to comment out the line extension=openssl in the PHP.ini file However, I don't have a PHP.ini file anywhere on my windows installation. http://localhost/phpinfp.php says that this file is in c:\Windows but there is no such file there.

I have got two files in my c:\PHP directory called php.ini-development and php.ini-production. However when I rename the first of these to php.ini and uncomment the line extension=openssl (restarting IIS afterwards) then PHP completely fails to function and calling contact.php generates a 500 error.

So, basically I need to either find what PHP.ini is really being used and edit that or find what line(s) in the development/production files are causing PHP to break and edit those.

It's php 7.2.4 on Windows 7

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
    • ¥15 画两个图 python或R
    • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
    • ¥15 八路抢答器设计出现故障