0

I am using php mailer to generate mails but the code works fine on local machine but when i uploaded the same on my server its giving this error (Extension missing: openssl Mailer Error: Extension missing: openssl), I have opened 587 port as well, Still its not working

require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();                                      
$mail->Host = 'smtp.gmail.com';  
$mail->SMTPAuth = true;                             
$mail->Username = 'abc@gmail.com';                 
$mail->Password = 'secret';                           
$mail->SMTPSecure = 'tls';   // Even ssl is not working                           
//$mail->Port = 587;                                  
$mail->setFrom('abc@gmail.com', 'abc');
$mail->addAddress('def@yahoo.com', 'DEF');     
$mail->isHTML(true);                                  
$mail->Subject = 'Subject here';
$mail->Body    = 'Body Goes here';
if(!$mail->send()) 
   echo 'Mailer Error: ' . $mail->ErrorInfo;
else
   echo 'Mail Sent';

Even i removed port no from the code it worked on local machine but not on server, I feel i have to make some changes on the server. i have checked server settings with phpinfo() function, The setting are almost similar like my local machine

Kashif
  • 15
  • 1
  • 8
  • Naïvely I would say that you need to install the openssl extension for PHP on your server. This does not seem to be an error within the code. – Jozef Legény Feb 16 '17 at 08:56

1 Answers1

0

"Almost" isn't good enough - you're missing the OpenSSL extension but you're asking PHPMailer to use encryption, which can't work without it. You just need to enable the openssl extension and it will work. There are many resources to help you do that such as this question, but you don't say what kind of server you're running so I can't be more specific.

Community
  • 1
  • 1
Synchro
  • 35,538
  • 15
  • 81
  • 104