2016-09-19 307 views
1

嗨,我想使用的PHPMailer其沒有工作給我的錯誤PHPMailer的錯誤連接:開放SSL://smtp.gmail.com:465,超時= 300,選擇=陣列()

Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()

這裏是我的代碼

 require_once('mailFiles/PHPMailerAutoload.php'); 
echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."<br/>"; 
       $mail = new PHPMailer(); 
       $mail->isSMTP(); 
       $mail->SMTPDebug = 4; 
       $mail->Debugoutput = 'html'; 
       $mail->SMTPAuth = true; 
       $mail->SMTPSecure = 'ssl'; 
    //   $mail->SMTPSecure = 'tls'; 
       $mail->Host = 'smtp.gmail.com'; 
    //   $mail->Host = gethostbyname('smtp.gmail.com'); 
    //   $mail->Host = 'tls://smtp.gmail.com:587'; 
    //   $mail->Port = 587; 
       $mail->Port = 465; 
       $mail->Username = "[email protected]"; 
       $mail->Password = "mailpass"; 
       $mail->setFrom('[email protected]', 'Firstz Last'); 
       $mail->addAddress('[email protected]', 'MAAGE-EMAIL User'); 
       $mail->IsHTML(true); 

       //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('Hi test 123'); 
       //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'); 
       $result = $mail->send(); 
       if (!$result) { 
        echo ("Mailer Error: "); 
        echo ($mail->ErrorInfo); 
       } else { 
        echo ("Message sent!"); 
       } 

已經厭倦TLS仍然沒有工作。

+0

$ mail-> Host ='tls://smtp.gmail.com:587'; –

+0

現在仍然不能正常工作獲取錯誤 連接:打開smtp.gmail.com:587,timeout = 300,options = array() SMTP錯誤:無法連接到服務器:嘗試訪問服務器中的套接字其訪問權限被禁止。 (10013) – OBAID

+0

我建議您閱讀[PHPMailer疑難解答指南](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting),並按照說明進行操作。也聽起來像你對PHP安裝有限制。 – Synchro

回答

0

問題出在我的防病毒軟件中,我使用的是McAfee,您需要更改其設置,請按照此link更改這些設置。我希望它也能幫助其他人。