Php – Resolve the error “PHPMailer Error: Extension missing: openssl”

phpphpmailer

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 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*******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";
?>

Please help me in resolving the error. I've enabled openssl in wampserver too.

Best Solution

PHP on IIS,

1) Open (php install directory)php.ini

2) Uncomment (~ line 910 in php.ini) extension=php_openssl.dll

3) Restart IIS

Related Question