require_once("phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port $mail->SetLanguage("en", "language/"); // $SMTPDebug = true; $mail->WordWrap = 50; $mail->Username = "prochniak@gmail.com"; // SMTP username $mail->Password = "xxxxxx"; // SMTP password $mail->SetFrom('prochniak@gmail.com', 'Prochniak'); $mail->AddAddress("prochniak@gmail.com"); $mail->Subject = "Test"; $message = 'Hello,'; $mail->MsgHTML($message); $mail->IsHTML(true); // send as HTML if(!$mail->Send()) { $msg = 'Message was not sent.<br>'; $msg .= 'Mailer error: ' . $mail->ErrorInfo; } else { $msg = 'Message has been sent.'; }
W wyniku wykonania powyższego kodu dostaje błąd:
SMTP Error: Could not connect to SMTP host.
Szukałem pomocy w necie, ale nie widzę gdzie mam błąd. Może ktoś spojrzeć z boku i sprawdzić?