php - PHPMailer working in browser but not working in command prompt -
i write code send mail using phpmailer
include 'class.phpmailer.php'; $mail = new phpmailer(); $mail->issmtp(); $mail->smtpauth = true; $mail->smtpsecure = 'ssl'; $mail->smtpdebug = 1; $mail->host = 'smtp.gmail.com'; $mail->port = 465; $mail->username = 'example1@gmail.com'; $mail->password = 'password'; $mail->setfrom('example2@gmail.com', 'admin'); $mail->addreplyto('example@yahoo.com', 'name'); $mail->addaddress('xample3@gmail.com'); $mail->subject = 'active email'; $mail->msghtml('click link active'); $mail->send();
when use browser can send mail, in command prompt,
php path_to_file
it not working,the error is:
smtp -> error: failed connect server: unable find socket transport ssl"....
i'd guess it's php configuration. http server , command line aren't using same file, , 1 used command line missing include of openssl extension.
use phpinfo()
function in command line find out file using:
php -r "phpinfo();"
then "loaded configuration file" line see file it's using. if windows server, need go file , add openssl extension appending it:
extension=php_openssl.dll
and make sure extension_dir
set the correct path; "ext" directory of php installation dir.
Comments
Post a Comment