php - PHPMailer, SMTP Failed to connect to server -
i'm using phpmailer. when upload host error smtp connect() failed.
my environment 1. server os:centos 7 2. web services: xampp 5.6.8 3. phpmailer:5.2.4
this code:
<?php require_once('phpmailer_old/class.phpmailer.php'); try{ $mail = new phpmailer(true); // true param means throw exceptions on errors, need catch $mail->issmtp(); // telling class use smtp $mail->smtpdebug = 1; // enables smtp debug information (for testing) $mail->smtpauth = true; // enable smtp authentication $mail->smtpsecure = "ssl"; $mail->smtpautotls = false; // close tls $mail->host = "smtp.gmail.com"; // sets gmail smtp server $mail->port = 465; // set smtp port gmail server $mail->username = "test@gmail.com"; // gmail username $mail->password = "test"; // gmaipassword $mail->fromname = "test manager"; $mail->from = "test@gmail.com"; $to = "test@hotmail.com"; $mail->addaddress($to); $mail->subject = "first phpmailer message"; $mail->altbody = "to view message, please use html compatible email viewer!"; $mail->wordwrap = 80; $body = "success!"; $mail->msghtml($body); $mail->ishtml(true); $mail->send(); echo "message has been sent."; }catch(phpmailerexception $e){ echo "sending failed"; echo $e -> errormessage(); } ?> error message in web: smtp -> error: failed connect server: (0) sending failedsmtp error: not connect smtp host.
thanks help! solution uninstall xampp , respectively install apache, php, mysql
Comments
Post a Comment