What is causing the error Extension missing: openssl using PHP Mailer class ?

Hi Experts!

I'm facing a problem when tryiing do send an email via PHPMailer with the code bellow.


Mailer Error: Extension missing: openssl


<?php
/**
 * This example shows settings to use when sending via Google's Gmail servers.
 */

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');

require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;

//Tell PHPMailer to use SMTP
$mail->isSMTP();

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;

//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';

//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
//$mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';

//Whether to use SMTP authentication
$mail->SMTPAuth = true;

//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "ed.xxxx@gmail.com";

//Password to use for SMTP authentication
$mail->Password = "xxxxx";

//Set who the message is to be sent from
$mail->setFrom('ed.xxxx@gmail.com', 'First Last');

//Set an alternative reply-to address
$mail->addReplyTo('exxxxx@uol.com.br', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('xxxx_ed@hotmail.com', 'John Doe');

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));

//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';

//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');


//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

Open in new window


I configured PHP.INI with
extension=php_openssl.dll

Could you point what must be done?

Thanks in advance
Eduardo FuerteDeveloper and AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marcus BointonCommented:
You need to restart your web server for this settings to take effect. Then run a script containing `<?php phpinfo(); ?>` and it will show you your settings. if you have a CLI SAPI of PHP, just run `php -m` and `php -i` to see what extensions you have installed.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Hello

After the steps that you pointed the error was suppressed but another one occurs....

SERVER -> CLIENT: 220 smtp.gmail.com ESMTP f19sm11660039qhc.18 - gsmtp
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [177.95.145.127]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [177.95.145.127]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH OAUTHBEARER250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 VXNlcm5hbWU6
CLIENT -> SERVER: ZWQuZnVlcnRlQGdtYWlsLmNvbQ==
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: ZWR1ZjIwMTU=
SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtYY534-5.7.14 4zXTKOYbglX5QcRHcml0-fTioVys-2_MfxJh4EBT8phRGZtYgYU8SSmYxSOYVcrKBiTDWt534-5.7.14 mwuesWlksWzlBYqxyer_wfkumXj1ouqadfXJXOMwSA2D_u57nbaZAWizy72qV_OcLqGGTK534-5.7.14 Uw5yRKciIMiXrcJ90HIpPjurNrateI8qSV4H5bhxS3gwvJbdd0LfqhaeWboVpRnfhDhr-L534-5.7.14 aMql7l-n5WflqKR5WZWcC9LooNQo> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 f19sm11660039qhc.18 - gsmtp
SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtYY534-5.7.14 4zXTKOYbglX5QcRHcml0-fTioVys-2_MfxJh4EBT8phRGZtYgYU8SSmYxSOYVcrKBiTDWt534-5.7.14 mwuesWlksWzlBYqxyer_wfkumXj1ouqadfXJXOMwSA2D_u57nbaZAWizy72qV_OcLqGGTK534-5.7.14 Uw5yRKciIMiXrcJ90HIpPjurNrateI8qSV4H5bhxS3gwvJbdd0LfqhaeWboVpRnfhDhr-L534-5.7.14 aMql7l-n5WflqKR5WZWcC9LooNQo> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 f19sm11660039qhc.18 - gsmtp
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 closing connection f19sm11660039qhc.18 - gsmtp
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Open in new window

0
Marcus BointonCommented:
So read the error message (it's there to help you!), and the docs it points to. Not rocket science.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Eduardo FuerteDeveloper and AnalystAuthor Commented:
I read.

I changed the host to Office365 - the original goal and it works very fine!

Thanks.
0
Marcus BointonCommented:
Glad you got it working. For anyone googling this, it works because Office365 only uses traditional authentication, not the XOAUTH2 mechanism that gmail requires by default. PHPMailer supports both, but XOAUTH2 is quite a bit more complex to set up.
0
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Yes... I got some emails from gmail advising me unauthorized someone tried access using depracated mechanisms.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.